<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP, ForeignFunctionInterface, BangPatterns #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE UnliftedFFITypes, MagicHash,
            UnboxedTuples, DeriveDataTypeable #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span class="hs-cpp">
#if __GLASGOW_HASKELL__ &gt;= 703
</span><span class="hs-pragma">{-# LANGUAGE Unsafe #-}</span><span class="hs-cpp">
#endif
</span><span class="hs-pragma">{-# OPTIONS_HADDOCK not-home #-}</span><span>
</span><span id="line-9"></span><span>
</span><span id="line-10"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- Module      : Data.ByteString.Internal</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Copyright   : (c) Don Stewart 2006-2008</span><span>
</span><span id="line-13"></span><span class="hs-comment">--               (c) Duncan Coutts 2006-2012</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- Maintainer  : dons00@gmail.com, duncan@community.haskell.org</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Stability   : unstable</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- Portability : non-portable</span><span>
</span><span id="line-18"></span><span class="hs-comment">--</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- A module containing semi-public 'ByteString' internals. This exposes the</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- 'ByteString' representation and low level construction functions. As such</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- all the functions in this module are unsafe. The API is also not stable.</span><span>
</span><span id="line-22"></span><span class="hs-comment">--</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- Where possible application should instead use the functions from the normal</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- public interface modules, such as &quot;Data.ByteString.Unsafe&quot;. Packages that</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- extend the ByteString system at a low level will need to use this module.</span><span>
</span><span id="line-26"></span><span class="hs-comment">--</span><span>
</span><span id="line-27"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.ByteString.Internal</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-28"></span><span>
</span><span id="line-29"></span><span>        </span><span class="annot"><span class="hs-comment">-- * The @ByteString@ type and representation</span></span><span>
</span><span id="line-30"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier">ByteString</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>         </span><span class="hs-comment">-- instances: Eq, Ord, Show, Read, Data, Typeable</span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Conversion with lists: packing and unpacking</span></span><span>
</span><span id="line-33"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#packBytes"><span class="hs-identifier">packBytes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#packUptoLenBytes"><span class="hs-identifier">packUptoLenBytes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafePackLenBytes"><span class="hs-identifier">unsafePackLenBytes</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-34"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#packChars"><span class="hs-identifier">packChars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#packUptoLenChars"><span class="hs-identifier">packUptoLenChars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafePackLenChars"><span class="hs-identifier">unsafePackLenChars</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-35"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#unpackBytes"><span class="hs-identifier">unpackBytes</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unpackAppendBytesLazy"><span class="hs-identifier">unpackAppendBytesLazy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unpackAppendBytesStrict"><span class="hs-identifier">unpackAppendBytesStrict</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-36"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#unpackChars"><span class="hs-identifier">unpackChars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unpackAppendCharsLazy"><span class="hs-identifier">unpackAppendCharsLazy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unpackAppendCharsStrict"><span class="hs-identifier">unpackAppendCharsStrict</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-37"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafePackAddress"><span class="hs-identifier">unsafePackAddress</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Low level imperative construction</span></span><span>
</span><span id="line-40"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#create"><span class="hs-identifier">create</span></a></span><span class="hs-special">,</span><span>                 </span><span class="hs-comment">-- :: Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ByteString</span><span>
</span><span id="line-41"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#createUptoN"><span class="hs-identifier">createUptoN</span></a></span><span class="hs-special">,</span><span>            </span><span class="hs-comment">-- :: Int -&gt; (Ptr Word8 -&gt; IO Int) -&gt; IO ByteString</span><span>
</span><span id="line-42"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#createUptoN%27"><span class="hs-identifier">createUptoN'</span></a></span><span class="hs-special">,</span><span>           </span><span class="hs-comment">-- :: Int -&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; IO (ByteString, a)</span><span>
</span><span id="line-43"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#createAndTrim"><span class="hs-identifier">createAndTrim</span></a></span><span class="hs-special">,</span><span>          </span><span class="hs-comment">-- :: Int -&gt; (Ptr Word8 -&gt; IO Int) -&gt; IO ByteString</span><span>
</span><span id="line-44"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#createAndTrim%27"><span class="hs-identifier">createAndTrim'</span></a></span><span class="hs-special">,</span><span>         </span><span class="hs-comment">-- :: Int -&gt; (Ptr Word8 -&gt; IO (Int, Int, a)) -&gt; IO (ByteString, a)</span><span>
</span><span id="line-45"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafeCreate"><span class="hs-identifier">unsafeCreate</span></a></span><span class="hs-special">,</span><span>           </span><span class="hs-comment">-- :: Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString</span><span>
</span><span id="line-46"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafeCreateUptoN"><span class="hs-identifier">unsafeCreateUptoN</span></a></span><span class="hs-special">,</span><span>      </span><span class="hs-comment">-- :: Int -&gt; (Ptr Word8 -&gt; IO Int) -&gt; ByteString</span><span>
</span><span id="line-47"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafeCreateUptoN%27"><span class="hs-identifier">unsafeCreateUptoN'</span></a></span><span class="hs-special">,</span><span>     </span><span class="hs-comment">-- :: Int -&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; (ByteString, a)</span><span>
</span><span id="line-48"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier">mallocByteString</span></a></span><span class="hs-special">,</span><span>       </span><span class="hs-comment">-- :: Int -&gt; IO (ForeignPtr a)</span><span>
</span><span id="line-49"></span><span>
</span><span id="line-50"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Conversion to and from ForeignPtrs</span></span><span>
</span><span id="line-51"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#fromForeignPtr"><span class="hs-identifier">fromForeignPtr</span></a></span><span class="hs-special">,</span><span>         </span><span class="hs-comment">-- :: ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString</span><span>
</span><span id="line-52"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#toForeignPtr"><span class="hs-identifier">toForeignPtr</span></a></span><span class="hs-special">,</span><span>           </span><span class="hs-comment">-- :: ByteString -&gt; (ForeignPtr Word8, Int, Int)</span><span>
</span><span id="line-53"></span><span>
</span><span id="line-54"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Utilities</span></span><span>
</span><span id="line-55"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#nullForeignPtr"><span class="hs-identifier">nullForeignPtr</span></a></span><span class="hs-special">,</span><span>         </span><span class="hs-comment">-- :: ForeignPtr Word8</span><span>
</span><span id="line-56"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#checkedAdd"><span class="hs-identifier">checkedAdd</span></a></span><span class="hs-special">,</span><span>             </span><span class="hs-comment">-- :: String -&gt; Int -&gt; Int -&gt; Int</span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Standard C Functions</span></span><span>
</span><span id="line-59"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#c_strlen"><span class="hs-identifier">c_strlen</span></a></span><span class="hs-special">,</span><span>               </span><span class="hs-comment">-- :: CString -&gt; IO CInt</span><span>
</span><span id="line-60"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#c_free_finalizer"><span class="hs-identifier">c_free_finalizer</span></a></span><span class="hs-special">,</span><span>       </span><span class="hs-comment">-- :: FunPtr (Ptr Word8 -&gt; IO ())</span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#memchr"><span class="hs-identifier">memchr</span></a></span><span class="hs-special">,</span><span>                 </span><span class="hs-comment">-- :: Ptr Word8 -&gt; Word8 -&gt; CSize -&gt; IO Ptr Word8</span><span>
</span><span id="line-63"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#memcmp"><span class="hs-identifier">memcmp</span></a></span><span class="hs-special">,</span><span>                 </span><span class="hs-comment">-- :: Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO CInt</span><span>
</span><span id="line-64"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#memcpy"><span class="hs-identifier">memcpy</span></a></span><span class="hs-special">,</span><span>                 </span><span class="hs-comment">-- :: Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()</span><span>
</span><span id="line-65"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#memset"><span class="hs-identifier">memset</span></a></span><span class="hs-special">,</span><span>                 </span><span class="hs-comment">-- :: Ptr Word8 -&gt; Word8 -&gt; CSize -&gt; IO (Ptr Word8)</span><span>
</span><span id="line-66"></span><span>
</span><span id="line-67"></span><span>        </span><span class="annot"><span class="hs-comment">-- * cbits functions</span></span><span>
</span><span id="line-68"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#c_reverse"><span class="hs-identifier">c_reverse</span></a></span><span class="hs-special">,</span><span>              </span><span class="hs-comment">-- :: Ptr Word8 -&gt; Ptr Word8 -&gt; CInt -&gt; IO ()</span><span>
</span><span id="line-69"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#c_intersperse"><span class="hs-identifier">c_intersperse</span></a></span><span class="hs-special">,</span><span>          </span><span class="hs-comment">-- :: Ptr Word8 -&gt; Ptr Word8 -&gt; CInt -&gt; Word8 -&gt; IO ()</span><span>
</span><span id="line-70"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#c_maximum"><span class="hs-identifier">c_maximum</span></a></span><span class="hs-special">,</span><span>              </span><span class="hs-comment">-- :: Ptr Word8 -&gt; CInt -&gt; IO Word8</span><span>
</span><span id="line-71"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#c_minimum"><span class="hs-identifier">c_minimum</span></a></span><span class="hs-special">,</span><span>              </span><span class="hs-comment">-- :: Ptr Word8 -&gt; CInt -&gt; IO Word8</span><span>
</span><span id="line-72"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#c_count"><span class="hs-identifier">c_count</span></a></span><span class="hs-special">,</span><span>                </span><span class="hs-comment">-- :: Ptr Word8 -&gt; CInt -&gt; Word8 -&gt; IO CInt</span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Chars</span></span><span>
</span><span id="line-75"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#w2c"><span class="hs-identifier">w2c</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#c2w"><span class="hs-identifier">c2w</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#isSpaceWord8"><span class="hs-identifier">isSpaceWord8</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#isSpaceChar8"><span class="hs-identifier">isSpaceChar8</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-76"></span><span>
</span><span id="line-77"></span><span>        </span><span class="annot"><span class="hs-comment">-- * Deprecated and unmentionable</span></span><span>
</span><span id="line-78"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#accursedUnutterablePerformIO"><span class="hs-identifier">accursedUnutterablePerformIO</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-comment">-- :: IO a -&gt; a</span><span>
</span><span id="line-79"></span><span>        </span><span class="annot"><a href="Data.ByteString.Internal.html#inlinePerformIO"><span class="hs-identifier">inlinePerformIO</span></a></span><span class="hs-special">,</span><span>              </span><span class="hs-comment">-- :: IO a -&gt; a</span><span>
</span><span id="line-80"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier">unsafeWithForeignPtr</span></a></span><span>
</span><span id="line-81"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-82"></span><span>
</span><span id="line-83"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier">concat</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier">null</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-84"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">List</span></span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.ForeignPtr.html#"><span class="hs-identifier">Foreign.ForeignPtr</span></a></span><span>       </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier">ForeignPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier">withForeignPtr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#if MIN_VERSION_base(4,15,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#"><span class="hs-identifier">GHC.ForeignPtr</span></a></span><span>           </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier">unsafeWithForeignPtr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Ptr.html#"><span class="hs-identifier">Foreign.Ptr</span></a></span><span>              </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#FunPtr"><span class="hs-identifier">FunPtr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-identifier">plusPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-91"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.Storable.html#"><span class="hs-identifier">Foreign.Storable</span></a></span><span>         </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Foreign.Storable.html#Storable"><span class="hs-identifier">Storable</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">

#if MIN_VERSION_base(4,5,0) || __GLASGOW_HASKELL__ &gt;= 703
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#"><span class="hs-identifier">Foreign.C.Types</span></a></span><span>          </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier">CInt</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier">CSize</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CULong"><span class="hs-identifier">CULong</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.C.Types</span><span>          </span><span class="hs-special">(</span><span class="hs-identifier">CInt</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">CSize</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">CULong</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-99"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.String.html#"><span class="hs-identifier">Foreign.C.String</span></a></span><span>         </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Foreign.C.String.html#CString"><span class="hs-identifier">CString</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#if MIN_VERSION_base(4,13,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Semigroup.html#"><span class="hs-identifier">Data.Semigroup</span></a></span><span>           </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Semigroup"><span class="hs-identifier">Semigroup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#sconcat"><span class="hs-identifier">sconcat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.NonEmpty.html#"><span class="hs-identifier">Data.List.NonEmpty</span></a></span><span>       </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#NonEmpty"><span class="hs-identifier">NonEmpty</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#%3A%7C"><span class="hs-operator">(:|)</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">
#elif MIN_VERSION_base(4,9,0)
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Semigroup</span><span>           </span><span class="hs-special">(</span><span class="hs-identifier">Semigroup</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-operator">&lt;&gt;</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">sconcat</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-106"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.List.NonEmpty</span><span>       </span><span class="hs-special">(</span><span class="hs-identifier">NonEmpty</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-operator">:|</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#if !(MIN_VERSION_base(4,8,0))
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Data.Monoid</span><span>              </span><span class="hs-special">(</span><span class="hs-identifier">Monoid</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-113"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#"><span class="hs-identifier">Control.DeepSeq</span></a></span><span>          </span><span class="hs-special">(</span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#NFData"><span class="hs-identifier">NFData</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#rnf"><span class="hs-identifier">rnf</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.String.html#"><span class="hs-identifier">Data.String</span></a></span><span>              </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.String.html#IsString"><span class="hs-identifier">IsString</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-116"></span><span>
</span><span id="line-117"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier">assert</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-118"></span><span>
</span><span id="line-119"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Char.html#"><span class="hs-identifier">Data.Char</span></a></span><span>                </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier">ord</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-120"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Word.html#"><span class="hs-identifier">Data.Word</span></a></span><span>                </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.html#"><span class="hs-identifier">Data.Typeable</span></a></span><span>            </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier">Typeable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Data.html#"><span class="hs-identifier">Data.Data</span></a></span><span>                </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Data.html#Data"><span class="hs-identifier">Data</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Data.html#mkNoRepType"><span class="hs-identifier">mkNoRepType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#"><span class="hs-identifier">GHC.Base</span></a></span><span>                 </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#nullAddr%23"><span class="hs-identifier">nullAddr#</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#realWorld%23"><span class="hs-identifier">realWorld#</span></a></span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.Base.html#unsafeChr"><span class="hs-identifier">unsafeChr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#if MIN_VERSION_base(4,7,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Exts.html#"><span class="hs-identifier">GHC.Exts</span></a></span><span>                 </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Exts.html#IsList"><span class="hs-identifier">IsList</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span class="hs-cpp">
#if MIN_VERSION_base(4,4,0)
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.CString.html#"><span class="hs-identifier">GHC.CString</span></a></span><span>              </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.CString.html#unpackCString%23"><span class="hs-identifier">unpackCString#</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.Base</span><span>                 </span><span class="hs-special">(</span><span class="hs-identifier">unpackCString#</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-137"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#"><span class="hs-identifier">GHC.Prim</span></a></span><span>                 </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Addr%23"><span class="hs-identifier">Addr#</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#if __GLASGOW_HASKELL__ &gt;= 611
</span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.IO.html#"><span class="hs-identifier">GHC.IO</span></a></span><span>                   </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier">IO</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier">IO</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.IO.Unsafe.html#unsafeDupablePerformIO"><span class="hs-identifier">unsafeDupablePerformIO</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">GHC.IOBase</span><span>               </span><span class="hs-special">(</span><span class="hs-identifier">IO</span><span class="hs-special">(</span><span class="hs-identifier">IO</span><span class="hs-special">)</span><span class="hs-special">,</span><span class="hs-identifier">RawBuffer</span><span class="hs-special">,</span><span class="hs-identifier">unsafeDupablePerformIO</span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-145"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#"><span class="hs-identifier">GHC.ForeignPtr</span></a></span><span>           </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier">ForeignPtr</span></a></span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier">ForeignPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-146"></span><span>                                </span><span class="hs-special">,</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#newForeignPtr_"><span class="hs-identifier">newForeignPtr_</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#mallocPlainForeignPtrBytes"><span class="hs-identifier">mallocPlainForeignPtrBytes</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-147"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#"><span class="hs-identifier">GHC.Ptr</span></a></span><span>                  </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#castPtr"><span class="hs-identifier">castPtr</span></a></span><span class="hs-special">)</span><span class="hs-cpp">

#if !MIN_VERSION_base(4,15,0)
</span><span class="hs-identifier">unsafeWithForeignPtr</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ForeignPtr</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">b</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">b</span><span>
</span><span id="line-151"></span><span class="hs-identifier">unsafeWithForeignPtr</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">withForeignPtr</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-154"></span><span>
</span><span id="line-155"></span><span class="hs-comment">-- CFILES stuff is Hugs only</span><span>
</span><span id="line-156"></span><span class="hs-pragma">{-# CFILES cbits/fpstring.c #-}</span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span class="hs-comment">-- -----------------------------------------------------------------------------</span><span>
</span><span id="line-159"></span><span>
</span><span id="line-160"></span><span class="hs-comment">-- | A space-efficient representation of a 'Word8' vector, supporting many</span><span>
</span><span id="line-161"></span><span class="hs-comment">-- efficient operations.</span><span>
</span><span id="line-162"></span><span class="hs-comment">--</span><span>
</span><span id="line-163"></span><span class="hs-comment">-- A 'ByteString' contains 8-bit bytes, or by using the operations from</span><span>
</span><span id="line-164"></span><span class="hs-comment">-- &quot;Data.ByteString.Char8&quot; it can be interpreted as containing 8-bit</span><span>
</span><span id="line-165"></span><span class="hs-comment">-- characters.</span><span>
</span><span id="line-166"></span><span class="hs-comment">--</span><span>
</span><span id="line-167"></span><span class="hs-keyword">data</span><span> </span><span id="ByteString"><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-var">ByteString</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="PS"><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span></span><span> </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- payload</span><span>
</span><span id="line-168"></span><span>                     </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>                </span><span class="hs-comment">-- offset</span><span>
</span><span id="line-169"></span><span>                     </span><span class="hs-pragma">{-# UNPACK</span><span> </span><span class="hs-pragma">#-}</span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>                </span><span class="hs-comment">-- length</span><span>
</span><span id="line-170"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679071346"><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#Eq"><span class="hs-identifier hs-type">Eq</span></a></span><span>  </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-173"></span><span>    </span><span id="local-6989586621679071344"><span class="annot"><span class="annottext">== :: ByteString -&gt; ByteString -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">(==)</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ByteString -&gt; Bool
</span><a href="Data.ByteString.Internal.html#eq"><span class="hs-identifier hs-var">eq</span></a></span><span>
</span><span id="line-174"></span><span>
</span><span id="line-175"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679071328"><span id="local-6989586621679071330"><span id="local-6989586621679071332"><span id="local-6989586621679071334"><span id="local-6989586621679071336"><span id="local-6989586621679071338"><span class="annot"><a href="../../ghc-prim/src/GHC.Classes.html#Ord"><span class="hs-identifier hs-type">Ord</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span></span></span></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-176"></span><span>    </span><span id="local-6989586621679071326"><span class="annot"><span class="annottext">compare :: ByteString -&gt; ByteString -&gt; Ordering
</span><a href="../../ghc-prim/src/GHC.Classes.html#compare"><span class="hs-identifier hs-var hs-var hs-var hs-var">compare</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ByteString -&gt; Ordering
</span><a href="Data.ByteString.Internal.html#compareBytes"><span class="hs-identifier hs-var">compareBytes</span></a></span><span class="hs-cpp">

#if MIN_VERSION_base(4,9,0)
</span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679071320"><span class="annot"><a href="../../base/src/GHC.Base.html#Semigroup"><span class="hs-identifier hs-type">Semigroup</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-180"></span><span>    </span><span id="local-6989586621679071318"><span class="annot"><span class="annottext">&lt;&gt; :: ByteString -&gt; ByteString -&gt; ByteString
</span><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;&gt;)</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ByteString -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#append"><span class="hs-identifier hs-var">append</span></a></span><span>
</span><span id="line-181"></span><span>    </span><span id="local-6989586621679071316"><span class="annot"><span class="annottext">sconcat :: NonEmpty ByteString -&gt; ByteString
</span><a href="#local-6989586621679071316"><span class="hs-identifier hs-var hs-var hs-var hs-var">sconcat</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679071315"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071315"><span class="hs-identifier hs-var">b</span></a></span></span><span class="annot"><a href="../../base/src/GHC.Base.html#%3A%7C"><span class="hs-operator hs-type">:|</span></a></span><span id="local-6989586621679071314"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071314"><span class="hs-identifier hs-var">bs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071315"><span class="hs-identifier hs-var">b</span></a></span><span class="annot"><span class="annottext">ByteString -&gt; [ByteString] -&gt; [ByteString]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071314"><span class="hs-identifier hs-var">bs</span></a></span><span class="hs-special">)</span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-184"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monoid"><span class="hs-identifier hs-type">Monoid</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-185"></span><span>    </span><span id="local-6989586621679071305"><span class="annot"><span class="annottext">mempty :: ByteString
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var hs-var hs-var hs-var">mempty</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="Data.ByteString.Internal.html#nullForeignPtr"><span class="hs-identifier hs-var">nullForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-cpp">
#if MIN_VERSION_base(4,9,0)
</span><span>    </span><span id="local-6989586621679071303"><span class="annot"><span class="annottext">mappend :: ByteString -&gt; ByteString -&gt; ByteString
</span><a href="../../base/src/GHC.Base.html#mappend"><span class="hs-identifier hs-var hs-var hs-var hs-var">mappend</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ByteString -&gt; ByteString
forall a. Semigroup a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">(&lt;&gt;)</span></a></span><span class="hs-cpp">
#else
</span><span>    </span><span class="hs-identifier">mappend</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">append</span><span class="hs-cpp">
#endif
</span><span>    </span><span id="local-6989586621679071302"><span class="annot"><span class="annottext">mconcat :: [ByteString] -&gt; ByteString
</span><a href="../../base/src/GHC.Base.html#mconcat"><span class="hs-identifier hs-var hs-var hs-var hs-var">mconcat</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span>
</span><span id="line-192"></span><span>
</span><span id="line-193"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="../../deepseq/src/Control.DeepSeq.html#NFData"><span class="hs-identifier hs-type">NFData</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-194"></span><span>    </span><span id="local-6989586621679071298"><span class="annot"><span class="annottext">rnf :: ByteString -&gt; ()
</span><a href="#local-6989586621679071298"><span class="hs-identifier hs-var hs-var hs-var hs-var">rnf</span></a></span></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-195"></span><span>
</span><span id="line-196"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679071293"><span id="local-6989586621679071295"><span class="annot"><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-type">Show</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-197"></span><span>    </span><span id="local-6989586621679071287"><span class="annot"><span class="annottext">showsPrec :: Int -&gt; ByteString -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showsPrec"><span class="hs-identifier hs-var hs-var hs-var hs-var">showsPrec</span></a></span></span><span> </span><span id="local-6989586621679071285"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071285"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679071284"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071284"><span class="hs-identifier hs-var">ps</span></a></span></span><span> </span><span id="local-6989586621679071283"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071283"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; String -&gt; ShowS
forall a. Show a =&gt; Int -&gt; a -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#showsPrec"><span class="hs-identifier hs-var">showsPrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071285"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ByteString -&gt; String
</span><a href="Data.ByteString.Internal.html#unpackChars"><span class="hs-identifier hs-var">unpackChars</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071284"><span class="hs-identifier hs-var">ps</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071283"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679071276"><span id="local-6989586621679071278"><span id="local-6989586621679071280"><span class="annot"><a href="../../base/src/GHC.Read.html#Read"><span class="hs-identifier hs-type">Read</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-200"></span><span>    </span><span id="local-6989586621679071270"><span class="annot"><span class="annottext">readsPrec :: Int -&gt; ReadS ByteString
</span><a href="../../base/src/GHC.Read.html#readsPrec"><span class="hs-identifier hs-var hs-var hs-var hs-var">readsPrec</span></a></span></span><span> </span><span id="local-6989586621679071268"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071268"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679071267"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071267"><span class="hs-identifier hs-var">str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#packChars"><span class="hs-identifier hs-var">packChars</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071266"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071265"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679071266"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071266"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679071265"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071265"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; ReadS String
forall a. Read a =&gt; Int -&gt; ReadS a
</span><a href="../../base/src/GHC.Read.html#readsPrec"><span class="hs-identifier hs-var">readsPrec</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071268"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071267"><span class="hs-identifier hs-var">str</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-cpp">

#if MIN_VERSION_base(4,7,0)
</span><span class="hs-comment">-- | @since 0.10.12.0</span><span>
</span><span id="line-204"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679071262"><span class="annot"><a href="../../base/src/GHC.Exts.html#IsList"><span class="hs-identifier hs-type">IsList</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-205"></span><span>  </span><span class="hs-keyword">type</span><span> </span><span id="Item"><span class="annot"><a href="../../base/src/GHC.Exts.html#Item"><span class="hs-identifier hs-var">Item</span></a></span></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-206"></span><span>  </span><span id="local-6989586621679071259"><span class="annot"><span class="annottext">fromList :: [Item ByteString] -&gt; ByteString
</span><a href="../../base/src/GHC.Exts.html#fromList"><span class="hs-identifier hs-var hs-var hs-var hs-var">fromList</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Word8] -&gt; ByteString
[Item ByteString] -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#packBytes"><span class="hs-identifier hs-var">packBytes</span></a></span><span>
</span><span id="line-207"></span><span>  </span><span id="local-6989586621679071258"><span class="annot"><span class="annottext">toList :: ByteString -&gt; [Item ByteString]
</span><a href="../../base/src/GHC.Exts.html#toList"><span class="hs-identifier hs-var hs-var hs-var hs-var">toList</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; [Word8]
ByteString -&gt; [Item ByteString]
</span><a href="Data.ByteString.Internal.html#unpackBytes"><span class="hs-identifier hs-var">unpackBytes</span></a></span><span class="hs-cpp">
#endif
</span><span>
</span><span id="line-210"></span><span class="hs-comment">-- | Beware: 'fromString' truncates multi-byte characters to octets.</span><span>
</span><span id="line-211"></span><span class="hs-comment">-- e.g. &quot;&#26543;&#26422;&#12395;&#28879;&#12398;&#12392;&#12414;&#12426;&#12369;&#12426;&#31179;&#12398;&#26286;&quot; becomes &#65533;6k&#65533;nh~&#65533;Q&#65533;&#65533;n&#65533;</span><span>
</span><span id="line-212"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="../../base/src/Data.String.html#IsString"><span class="hs-identifier hs-type">IsString</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-213"></span><span>    </span><span id="local-6989586621679071254"><span class="annot"><span class="annottext">fromString :: String -&gt; ByteString
</span><a href="../../base/src/Data.String.html#fromString"><span class="hs-identifier hs-var hs-var hs-var hs-var">fromString</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#packChars"><span class="hs-identifier hs-var">packChars</span></a></span><span>
</span><span id="line-214"></span><span>
</span><span id="line-215"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679071228"><span id="local-6989586621679071230"><span id="local-6989586621679071232"><span id="local-6989586621679071234"><span id="local-6989586621679071236"><span id="local-6989586621679071238"><span id="local-6989586621679071240"><span id="local-6989586621679071242"><span id="local-6989586621679071244"><span id="local-6989586621679071246"><span class="annot"><a href="../../base/src/Data.Data.html#Data"><span class="hs-identifier hs-type">Data</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span></span></span></span></span></span></span></span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-216"></span><span>  </span><span id="local-6989586621679071222"><span class="annot"><span class="annottext">gfoldl :: forall (c :: * -&gt; *).
(forall d b. Data d =&gt; c (d -&gt; b) -&gt; d -&gt; c b)
-&gt; (forall g. g -&gt; c g) -&gt; ByteString -&gt; c ByteString
</span><a href="../../base/src/Data.Data.html#gfoldl"><span class="hs-identifier hs-var hs-var hs-var hs-var">gfoldl</span></a></span></span><span> </span><span id="local-6989586621679071220"><span class="annot"><span class="annottext">forall d b. Data d =&gt; c (d -&gt; b) -&gt; d -&gt; c b
</span><a href="#local-6989586621679071220"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679071219"><span class="annot"><span class="annottext">forall g. g -&gt; c g
</span><a href="#local-6989586621679071219"><span class="hs-identifier hs-var">z</span></a></span></span><span> </span><span id="local-6989586621679071218"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071218"><span class="hs-identifier hs-var">txt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([Word8] -&gt; ByteString) -&gt; c ([Word8] -&gt; ByteString)
forall g. g -&gt; c g
</span><a href="#local-6989586621679071219"><span class="hs-identifier hs-var">z</span></a></span><span> </span><span class="annot"><span class="annottext">[Word8] -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#packBytes"><span class="hs-identifier hs-var">packBytes</span></a></span><span> </span><span class="annot"><span class="annottext">c ([Word8] -&gt; ByteString) -&gt; [Word8] -&gt; c ByteString
forall d b. Data d =&gt; c (d -&gt; b) -&gt; d -&gt; c b
</span><a href="#local-6989586621679071220"><span class="hs-operator hs-var">`f`</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; [Word8]
</span><a href="Data.ByteString.Internal.html#unpackBytes"><span class="hs-identifier hs-var">unpackBytes</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071218"><span class="hs-identifier hs-var">txt</span></a></span><span>
</span><span id="line-217"></span><span>  </span><span id="local-6989586621679071215"><span class="annot"><span class="annottext">toConstr :: ByteString -&gt; Constr
</span><a href="../../base/src/Data.Data.html#toConstr"><span class="hs-identifier hs-var hs-var hs-var hs-var">toConstr</span></a></span></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Constr
forall a. (?callStack::CallStack) =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Data.ByteString.ByteString.toConstr&quot;</span></span><span>
</span><span id="line-218"></span><span>  </span><span id="local-6989586621679071210"><span class="annot"><span class="annottext">gunfold :: forall (c :: * -&gt; *).
(forall b r. Data b =&gt; c (b -&gt; r) -&gt; c r)
-&gt; (forall r. r -&gt; c r) -&gt; Constr -&gt; c ByteString
</span><a href="../../base/src/Data.Data.html#gunfold"><span class="hs-identifier hs-var hs-var hs-var hs-var">gunfold</span></a></span></span><span> </span><span class="annot"><span class="annottext">forall b r. Data b =&gt; c (b -&gt; r) -&gt; c r
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">forall r. r -&gt; c r
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Constr -&gt; c ByteString
forall a. (?callStack::CallStack) =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Data.ByteString.ByteString.gunfold&quot;</span></span><span>
</span><span id="line-219"></span><span>  </span><span id="local-6989586621679071208"><span class="annot"><span class="annottext">dataTypeOf :: ByteString -&gt; DataType
</span><a href="../../base/src/Data.Data.html#dataTypeOf"><span class="hs-identifier hs-var hs-var hs-var hs-var">dataTypeOf</span></a></span></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; DataType
</span><a href="../../base/src/Data.Data.html#mkNoRepType"><span class="hs-identifier hs-var">mkNoRepType</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Data.ByteString.ByteString&quot;</span></span><span>
</span><span id="line-220"></span><span>
</span><span id="line-221"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-222"></span><span class="hs-comment">-- Packing and unpacking from lists</span><span>
</span><span id="line-223"></span><span>
</span><span id="line-224"></span><span class="annot"><a href="Data.ByteString.Internal.html#packBytes"><span class="hs-identifier hs-type">packBytes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-225"></span><span id="packBytes"><span class="annot"><span class="annottext">packBytes :: [Word8] -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#packBytes"><span class="hs-identifier hs-var hs-var">packBytes</span></a></span></span><span> </span><span id="local-6989586621679071206"><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071206"><span class="hs-identifier hs-var">ws</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; [Word8] -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafePackLenBytes"><span class="hs-identifier hs-var">unsafePackLenBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Word8] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">List.length</span></a></span><span> </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071206"><span class="hs-identifier hs-var">ws</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071206"><span class="hs-identifier hs-var">ws</span></a></span><span>
</span><span id="line-226"></span><span>
</span><span id="line-227"></span><span class="annot"><a href="Data.ByteString.Internal.html#packChars"><span class="hs-identifier hs-type">packChars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-228"></span><span id="packChars"><span class="annot"><span class="annottext">packChars :: String -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#packChars"><span class="hs-identifier hs-var hs-var">packChars</span></a></span></span><span> </span><span id="local-6989586621679071204"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071204"><span class="hs-identifier hs-var">cs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; String -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafePackLenChars"><span class="hs-identifier hs-var">unsafePackLenChars</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">List.length</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071204"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071204"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-229"></span><span>
</span><span id="line-230"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">[</span><span class="hs-pragma">0</span><span class="hs-pragma">]</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#packChars"><span class="hs-pragma hs-type">packChars</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-231"></span><span>
</span><span id="line-232"></span><span class="hs-pragma">{-# RULES</span><span>
</span><span id="line-233"></span><span class="annot"><span class="hs-pragma">&quot;ByteString packChars/packAddress&quot;</span></span><span> </span><span class="hs-pragma">forall</span><span> </span><span id="local-6989586621679071203"><span class="annot"><a href="#local-6989586621679071203"><span class="hs-pragma hs-var">s</span></a></span></span><span> </span><span class="hs-pragma">.</span><span>
</span><span id="line-234"></span><span>   </span><span class="annot"><a href="Data.ByteString.Internal.html#packChars"><span class="hs-pragma hs-type">packChars</span></a></span><span> </span><span class="hs-pragma">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.CString.html#unpackCString%23"><span class="hs-pragma hs-type">unpackCString#</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679071203"><span class="hs-pragma hs-type">s</span></a></span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">=</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#accursedUnutterablePerformIO"><span class="hs-pragma hs-type">accursedUnutterablePerformIO</span></a></span><span> </span><span class="hs-pragma">(</span><span class="annot"><a href="Data.ByteString.Internal.html#unsafePackAddress"><span class="hs-pragma hs-type">unsafePackAddress</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679071203"><span class="hs-pragma hs-type">s</span></a></span><span class="hs-pragma">)</span><span>
</span><span id="line-235"></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-236"></span><span>
</span><span id="line-237"></span><span class="annot"><a href="Data.ByteString.Internal.html#unsafePackLenBytes"><span class="hs-identifier hs-type">unsafePackLenBytes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-238"></span><span id="unsafePackLenBytes"><span class="annot"><span class="annottext">unsafePackLenBytes :: Int -&gt; [Word8] -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafePackLenBytes"><span class="hs-identifier hs-var hs-var">unsafePackLenBytes</span></a></span></span><span> </span><span id="local-6989586621679071202"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071202"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621679071201"><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071201"><span class="hs-identifier hs-var">xs0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-239"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafeCreate"><span class="hs-identifier hs-var">unsafeCreate</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071202"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; ByteString)
-&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071200"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071200"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; [Word8] -&gt; IO ()
forall {b}. Storable b =&gt; Ptr b -&gt; [b] -&gt; IO ()
</span><a href="#local-6989586621679071199"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071200"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071201"><span class="hs-identifier hs-var">xs0</span></a></span><span>
</span><span id="line-240"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-241"></span><span>    </span><span id="local-6989586621679071199"><span class="annot"><span class="annottext">go :: Ptr b -&gt; [b] -&gt; IO ()
</span><a href="#local-6989586621679071199"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Ptr b
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-242"></span><span>    </span><span class="annot"><a href="#local-6989586621679071199"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071194"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071194"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679071193"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679071193"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679071192"><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621679071192"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; b -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#poke"><span class="hs-identifier hs-var">poke</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071194"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679071193"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; [b] -&gt; IO ()
</span><a href="#local-6989586621679071199"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071194"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621679071192"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-243"></span><span>
</span><span id="line-244"></span><span class="annot"><a href="Data.ByteString.Internal.html#unsafePackLenChars"><span class="hs-identifier hs-type">unsafePackLenChars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-245"></span><span id="unsafePackLenChars"><span class="annot"><span class="annottext">unsafePackLenChars :: Int -&gt; String -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafePackLenChars"><span class="hs-identifier hs-var hs-var">unsafePackLenChars</span></a></span></span><span> </span><span id="local-6989586621679071190"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071190"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621679071189"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071189"><span class="hs-identifier hs-var">cs0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-246"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafeCreate"><span class="hs-identifier hs-var">unsafeCreate</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071190"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; ByteString)
-&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071188"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071188"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; String -&gt; IO ()
</span><a href="#local-6989586621679071187"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071188"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071189"><span class="hs-identifier hs-var">cs0</span></a></span><span>
</span><span id="line-247"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-248"></span><span>    </span><span id="local-6989586621679071187"><span class="annot"><span class="annottext">go :: Ptr Word8 -&gt; String -&gt; IO ()
</span><a href="#local-6989586621679071187"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Ptr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-249"></span><span>    </span><span class="annot"><a href="#local-6989586621679071187"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071183"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071183"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679071182"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679071182"><span class="hs-identifier hs-var">c</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679071181"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071181"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Word8 -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#poke"><span class="hs-identifier hs-var">poke</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071183"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Word8
</span><a href="Data.ByteString.Internal.html#c2w"><span class="hs-identifier hs-var">c2w</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679071182"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; String -&gt; IO ()
</span><a href="#local-6989586621679071187"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071183"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071181"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-250"></span><span>
</span><span id="line-251"></span><span>
</span><span id="line-252"></span><span class="hs-comment">-- | /O(n)/ Pack a null-terminated sequence of bytes, pointed to by an</span><span>
</span><span id="line-253"></span><span class="hs-comment">-- Addr\# (an arbitrary machine address assumed to point outside the</span><span>
</span><span id="line-254"></span><span class="hs-comment">-- garbage-collected heap) into a @ByteString@. A much faster way to</span><span>
</span><span id="line-255"></span><span class="hs-comment">-- create an 'Addr#' is with an unboxed string literal, than to pack a</span><span>
</span><span id="line-256"></span><span class="hs-comment">-- boxed string. A unboxed string literal is compiled to a static @char</span><span>
</span><span id="line-257"></span><span class="hs-comment">-- []@ by GHC. Establishing the length of the string requires a call to</span><span>
</span><span id="line-258"></span><span class="hs-comment">-- @strlen(3)@, so the 'Addr#' must point to a null-terminated buffer (as</span><span>
</span><span id="line-259"></span><span class="hs-comment">-- is the case with @\&quot;string\&quot;\#@ literals in GHC). Use 'Data.ByteString.Unsafe.unsafePackAddressLen'</span><span>
</span><span id="line-260"></span><span class="hs-comment">-- if you know the length of the string statically.</span><span>
</span><span id="line-261"></span><span class="hs-comment">--</span><span>
</span><span id="line-262"></span><span class="hs-comment">-- An example:</span><span>
</span><span id="line-263"></span><span class="hs-comment">--</span><span>
</span><span id="line-264"></span><span class="hs-comment">-- &gt; literalFS = unsafePackAddress &quot;literal&quot;#</span><span>
</span><span id="line-265"></span><span class="hs-comment">--</span><span>
</span><span id="line-266"></span><span class="hs-comment">-- This function is /unsafe/. If you modify the buffer pointed to by the</span><span>
</span><span id="line-267"></span><span class="hs-comment">-- original 'Addr#' this modification will be reflected in the resulting</span><span>
</span><span id="line-268"></span><span class="hs-comment">-- @ByteString@, breaking referential transparency.</span><span>
</span><span id="line-269"></span><span class="hs-comment">--</span><span>
</span><span id="line-270"></span><span class="hs-comment">-- Note this also won't work if your 'Addr#' has embedded @\'\\0\'@ characters in</span><span>
</span><span id="line-271"></span><span class="hs-comment">-- the string, as @strlen@ will return too short a length.</span><span>
</span><span id="line-272"></span><span class="hs-comment">--</span><span>
</span><span id="line-273"></span><span class="annot"><a href="Data.ByteString.Internal.html#unsafePackAddress"><span class="hs-identifier hs-type">unsafePackAddress</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Addr%23"><span class="hs-identifier hs-type">Addr#</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-274"></span><span id="unsafePackAddress"><span class="annot"><span class="annottext">unsafePackAddress :: Addr# -&gt; IO ByteString
</span><a href="Data.ByteString.Internal.html#unsafePackAddress"><span class="hs-identifier hs-var hs-var">unsafePackAddress</span></a></span></span><span> </span><span id="local-6989586621679071180"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679071180"><span class="hs-identifier hs-var">addr#</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-275"></span><span>    </span><span id="local-6989586621679071179"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071179"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (ForeignPtr Word8)
forall a. Ptr a -&gt; IO (ForeignPtr a)
</span><a href="../../base/src/GHC.ForeignPtr.html#newForeignPtr_"><span class="hs-identifier hs-var">newForeignPtr_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr CChar -&gt; Ptr Word8
forall a b. Ptr a -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#castPtr"><span class="hs-identifier hs-var">castPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CChar
</span><a href="#local-6989586621679071178"><span class="hs-identifier hs-var">cstr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-276"></span><span>    </span><span id="local-6989586621679071177"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679071177"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr CChar -&gt; IO CSize
</span><a href="Data.ByteString.Internal.html#c_strlen"><span class="hs-identifier hs-var">c_strlen</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr CChar
</span><a href="#local-6989586621679071178"><span class="hs-identifier hs-var">cstr</span></a></span><span>
</span><span id="line-277"></span><span>    </span><span class="annot"><span class="annottext">ByteString -&gt; IO ByteString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteString -&gt; IO ByteString) -&gt; ByteString -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071179"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CSize -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679071177"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-278"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-279"></span><span>    </span><span class="annot"><a href="#local-6989586621679071178"><span class="hs-identifier hs-type">cstr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.String.html#CString"><span class="hs-identifier hs-type">CString</span></a></span><span>
</span><span id="line-280"></span><span>    </span><span id="local-6989586621679071178"><span class="annot"><span class="annottext">cstr :: Ptr CChar
</span><a href="#local-6989586621679071178"><span class="hs-identifier hs-var hs-var">cstr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; Ptr CChar
forall a. Addr# -&gt; Ptr a
</span><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-var">Ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679071180"><span class="hs-identifier hs-var">addr#</span></a></span><span>
</span><span id="line-281"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafePackAddress"><span class="hs-pragma hs-type">unsafePackAddress</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-282"></span><span>
</span><span id="line-283"></span><span>
</span><span id="line-284"></span><span class="annot"><a href="Data.ByteString.Internal.html#packUptoLenBytes"><span class="hs-identifier hs-type">packUptoLenBytes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-285"></span><span id="packUptoLenBytes"><span class="annot"><span class="annottext">packUptoLenBytes :: Int -&gt; [Word8] -&gt; (ByteString, [Word8])
</span><a href="Data.ByteString.Internal.html#packUptoLenBytes"><span class="hs-identifier hs-var hs-var">packUptoLenBytes</span></a></span></span><span> </span><span id="local-6989586621679071175"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071175"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621679071174"><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071174"><span class="hs-identifier hs-var">xs0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-286"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO (Int, [Word8])) -&gt; (ByteString, [Word8])
forall a. Int -&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; (ByteString, a)
</span><a href="Data.ByteString.Internal.html#unsafeCreateUptoN%27"><span class="hs-identifier hs-var">unsafeCreateUptoN'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071175"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO (Int, [Word8])) -&gt; (ByteString, [Word8]))
-&gt; (Ptr Word8 -&gt; IO (Int, [Word8])) -&gt; (ByteString, [Word8])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071173"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071173"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; [Word8] -&gt; IO (Int, [Word8])
</span><a href="#local-6989586621679071172"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071173"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071175"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071174"><span class="hs-identifier hs-var">xs0</span></a></span><span>
</span><span id="line-287"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-288"></span><span>    </span><span id="local-6989586621679071172"><span class="annot"><span class="annottext">go :: Ptr Word8 -&gt; Int -&gt; [Word8] -&gt; IO (Int, [Word8])
</span><a href="#local-6989586621679071172"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Ptr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071171"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071171"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int, [Word8]) -&gt; IO (Int, [Word8])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071175"><span class="hs-identifier hs-var">len</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071171"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-289"></span><span>    </span><span class="annot"><a href="#local-6989586621679071172"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Ptr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621679071170"><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071170"><span class="hs-identifier hs-var">xs</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int, [Word8]) -&gt; IO (Int, [Word8])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071175"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071170"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-290"></span><span>    </span><span class="annot"><a href="#local-6989586621679071172"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071169"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071169"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071168"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071168"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679071167"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679071167"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679071166"><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071166"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Word8 -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#poke"><span class="hs-identifier hs-var">poke</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071169"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679071167"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO (Int, [Word8]) -&gt; IO (Int, [Word8])
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; [Word8] -&gt; IO (Int, [Word8])
</span><a href="#local-6989586621679071172"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071169"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071168"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071166"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-291"></span><span>
</span><span id="line-292"></span><span class="annot"><a href="Data.ByteString.Internal.html#packUptoLenChars"><span class="hs-identifier hs-type">packUptoLenChars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-293"></span><span id="packUptoLenChars"><span class="annot"><span class="annottext">packUptoLenChars :: Int -&gt; String -&gt; (ByteString, String)
</span><a href="Data.ByteString.Internal.html#packUptoLenChars"><span class="hs-identifier hs-var hs-var">packUptoLenChars</span></a></span></span><span> </span><span id="local-6989586621679071165"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071165"><span class="hs-identifier hs-var">len</span></a></span></span><span> </span><span id="local-6989586621679071164"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071164"><span class="hs-identifier hs-var">cs0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-294"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO (Int, String)) -&gt; (ByteString, String)
forall a. Int -&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; (ByteString, a)
</span><a href="Data.ByteString.Internal.html#unsafeCreateUptoN%27"><span class="hs-identifier hs-var">unsafeCreateUptoN'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071165"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO (Int, String)) -&gt; (ByteString, String))
-&gt; (Ptr Word8 -&gt; IO (Int, String)) -&gt; (ByteString, String)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071163"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071163"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; String -&gt; IO (Int, String)
</span><a href="#local-6989586621679071162"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071163"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071165"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071164"><span class="hs-identifier hs-var">cs0</span></a></span><span>
</span><span id="line-295"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-296"></span><span>    </span><span id="local-6989586621679071162"><span class="annot"><span class="annottext">go :: Ptr Word8 -&gt; Int -&gt; String -&gt; IO (Int, String)
</span><a href="#local-6989586621679071162"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Ptr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071161"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071161"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int, String) -&gt; IO (Int, String)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071165"><span class="hs-identifier hs-var">len</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071161"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-297"></span><span>    </span><span class="annot"><a href="#local-6989586621679071162"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Ptr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span id="local-6989586621679071160"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071160"><span class="hs-identifier hs-var">cs</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int, String) -&gt; IO (Int, String)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071165"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">,</span><span>   </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071160"><span class="hs-identifier hs-var">cs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-298"></span><span>    </span><span class="annot"><a href="#local-6989586621679071162"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071159"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071159"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071158"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071158"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679071157"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679071157"><span class="hs-identifier hs-var">c</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679071156"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071156"><span class="hs-identifier hs-var">cs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Word8 -&gt; IO ()
forall a. Storable a =&gt; Ptr a -&gt; a -&gt; IO ()
</span><a href="../../base/src/Foreign.Storable.html#poke"><span class="hs-identifier hs-var">poke</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071159"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Word8
</span><a href="Data.ByteString.Internal.html#c2w"><span class="hs-identifier hs-var">c2w</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679071157"><span class="hs-identifier hs-var">c</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; IO (Int, String) -&gt; IO (Int, String)
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; String -&gt; IO (Int, String)
</span><a href="#local-6989586621679071162"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071159"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071158"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071156"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-299"></span><span>
</span><span id="line-300"></span><span class="hs-comment">-- Unpacking bytestrings into lists efficiently is a tradeoff: on the one hand</span><span>
</span><span id="line-301"></span><span class="hs-comment">-- we would like to write a tight loop that just blasts the list into memory, on</span><span>
</span><span id="line-302"></span><span class="hs-comment">-- the other hand we want it to be unpacked lazily so we don't end up with a</span><span>
</span><span id="line-303"></span><span class="hs-comment">-- massive list data structure in memory.</span><span>
</span><span id="line-304"></span><span class="hs-comment">--</span><span>
</span><span id="line-305"></span><span class="hs-comment">-- Our strategy is to combine both: we will unpack lazily in reasonable sized</span><span>
</span><span id="line-306"></span><span class="hs-comment">-- chunks, where each chunk is unpacked strictly.</span><span>
</span><span id="line-307"></span><span class="hs-comment">--</span><span>
</span><span id="line-308"></span><span class="hs-comment">-- unpackBytes and unpackChars do the lazy loop, while unpackAppendBytes and</span><span>
</span><span id="line-309"></span><span class="hs-comment">-- unpackAppendChars do the chunks strictly.</span><span>
</span><span id="line-310"></span><span>
</span><span id="line-311"></span><span class="annot"><a href="Data.ByteString.Internal.html#unpackBytes"><span class="hs-identifier hs-type">unpackBytes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-312"></span><span id="unpackBytes"><span class="annot"><span class="annottext">unpackBytes :: ByteString -&gt; [Word8]
</span><a href="Data.ByteString.Internal.html#unpackBytes"><span class="hs-identifier hs-var hs-var">unpackBytes</span></a></span></span><span> </span><span id="local-6989586621679071155"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071155"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; [Word8] -&gt; [Word8]
</span><a href="Data.ByteString.Internal.html#unpackAppendBytesLazy"><span class="hs-identifier hs-var">unpackAppendBytesLazy</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071155"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-313"></span><span>
</span><span id="line-314"></span><span class="annot"><a href="Data.ByteString.Internal.html#unpackChars"><span class="hs-identifier hs-type">unpackChars</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-315"></span><span id="unpackChars"><span class="annot"><span class="annottext">unpackChars :: ByteString -&gt; String
</span><a href="Data.ByteString.Internal.html#unpackChars"><span class="hs-identifier hs-var hs-var">unpackChars</span></a></span></span><span> </span><span id="local-6989586621679071154"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071154"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ShowS
</span><a href="Data.ByteString.Internal.html#unpackAppendCharsLazy"><span class="hs-identifier hs-var">unpackAppendCharsLazy</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071154"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-316"></span><span>
</span><span id="line-317"></span><span class="annot"><a href="Data.ByteString.Internal.html#unpackAppendBytesLazy"><span class="hs-identifier hs-type">unpackAppendBytesLazy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-318"></span><span id="unpackAppendBytesLazy"><span class="annot"><span class="annottext">unpackAppendBytesLazy :: ByteString -&gt; [Word8] -&gt; [Word8]
</span><a href="Data.ByteString.Internal.html#unpackAppendBytesLazy"><span class="hs-identifier hs-var hs-var">unpackAppendBytesLazy</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071153"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071153"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679071152"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071152"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679071151"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071151"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679071150"><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071150"><span class="hs-identifier hs-var">xs</span></a></span></span><span>
</span><span id="line-319"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071151"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">100</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; [Word8] -&gt; [Word8]
</span><a href="Data.ByteString.Internal.html#unpackAppendBytesStrict"><span class="hs-identifier hs-var">unpackAppendBytesStrict</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071153"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071152"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071151"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071150"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-320"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; [Word8] -&gt; [Word8]
</span><a href="Data.ByteString.Internal.html#unpackAppendBytesStrict"><span class="hs-identifier hs-var">unpackAppendBytesStrict</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071153"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071152"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">100</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071148"><span class="hs-identifier hs-var">remainder</span></a></span><span>
</span><span id="line-321"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-322"></span><span>    </span><span id="local-6989586621679071148"><span class="annot"><span class="annottext">remainder :: [Word8]
</span><a href="#local-6989586621679071148"><span class="hs-identifier hs-var hs-var">remainder</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; [Word8] -&gt; [Word8]
</span><a href="Data.ByteString.Internal.html#unpackAppendBytesLazy"><span class="hs-identifier hs-var">unpackAppendBytesLazy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071153"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071152"><span class="hs-identifier hs-var">off</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">100</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071151"><span class="hs-identifier hs-var">len</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">100</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071150"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-323"></span><span>
</span><span id="line-324"></span><span>  </span><span class="hs-comment">-- Why 100 bytes you ask? Because on a 64bit machine the list we allocate</span><span>
</span><span id="line-325"></span><span>  </span><span class="hs-comment">-- takes just shy of 4k which seems like a reasonable amount.</span><span>
</span><span id="line-326"></span><span>  </span><span class="hs-comment">-- (5 words per list element, 8 bytes per word, 100 elements = 4000 bytes)</span><span>
</span><span id="line-327"></span><span>
</span><span id="line-328"></span><span class="annot"><a href="Data.ByteString.Internal.html#unpackAppendCharsLazy"><span class="hs-identifier hs-type">unpackAppendCharsLazy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-329"></span><span id="unpackAppendCharsLazy"><span class="annot"><span class="annottext">unpackAppendCharsLazy :: ByteString -&gt; ShowS
</span><a href="Data.ByteString.Internal.html#unpackAppendCharsLazy"><span class="hs-identifier hs-var hs-var">unpackAppendCharsLazy</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071146"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071146"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679071145"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071145"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679071144"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071144"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679071143"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071143"><span class="hs-identifier hs-var">cs</span></a></span></span><span>
</span><span id="line-330"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071144"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">100</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ShowS
</span><a href="Data.ByteString.Internal.html#unpackAppendCharsStrict"><span class="hs-identifier hs-var">unpackAppendCharsStrict</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071146"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071145"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071144"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071143"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-331"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ShowS
</span><a href="Data.ByteString.Internal.html#unpackAppendCharsStrict"><span class="hs-identifier hs-var">unpackAppendCharsStrict</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071146"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071145"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">100</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071142"><span class="hs-identifier hs-var">remainder</span></a></span><span>
</span><span id="line-332"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-333"></span><span>    </span><span id="local-6989586621679071142"><span class="annot"><span class="annottext">remainder :: String
</span><a href="#local-6989586621679071142"><span class="hs-identifier hs-var hs-var">remainder</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ShowS
</span><a href="Data.ByteString.Internal.html#unpackAppendCharsLazy"><span class="hs-identifier hs-var">unpackAppendCharsLazy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071146"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071145"><span class="hs-identifier hs-var">off</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">100</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071144"><span class="hs-identifier hs-var">len</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">100</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071143"><span class="hs-identifier hs-var">cs</span></a></span><span>
</span><span id="line-334"></span><span>
</span><span id="line-335"></span><span class="hs-comment">-- For these unpack functions, since we're unpacking the whole list strictly we</span><span>
</span><span id="line-336"></span><span class="hs-comment">-- build up the result list in an accumulator. This means we have to build up</span><span>
</span><span id="line-337"></span><span class="hs-comment">-- the list starting at the end. So our traversal starts at the end of the</span><span>
</span><span id="line-338"></span><span class="hs-comment">-- buffer and loops down until we hit the sentinal:</span><span>
</span><span id="line-339"></span><span>
</span><span id="line-340"></span><span class="annot"><a href="Data.ByteString.Internal.html#unpackAppendBytesStrict"><span class="hs-identifier hs-type">unpackAppendBytesStrict</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-341"></span><span id="unpackAppendBytesStrict"><span class="annot"><span class="annottext">unpackAppendBytesStrict :: ByteString -&gt; [Word8] -&gt; [Word8]
</span><a href="Data.ByteString.Internal.html#unpackAppendBytesStrict"><span class="hs-identifier hs-var hs-var">unpackAppendBytesStrict</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071141"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071141"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679071140"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071140"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679071139"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071139"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679071138"><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071138"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-342"></span><span>    </span><span class="annot"><span class="annottext">IO [Word8] -&gt; [Word8]
forall a. IO a -&gt; a
</span><a href="Data.ByteString.Internal.html#accursedUnutterablePerformIO"><span class="hs-identifier hs-var">accursedUnutterablePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO [Word8] -&gt; [Word8]) -&gt; IO [Word8] -&gt; [Word8]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO [Word8]) -&gt; IO [Word8]
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071141"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO [Word8]) -&gt; IO [Word8])
-&gt; (Ptr Word8 -&gt; IO [Word8]) -&gt; IO [Word8]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071137"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071137"><span class="hs-identifier hs-var">base</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-343"></span><span>      </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; [Word8] -&gt; IO [Word8]
forall {b}. Storable b =&gt; Ptr b -&gt; Ptr b -&gt; [b] -&gt; IO [b]
</span><a href="#local-6989586621679071136"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071137"><span class="hs-identifier hs-var">base</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071140"><span class="hs-identifier hs-var">off</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071137"><span class="hs-identifier hs-var">base</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071140"><span class="hs-identifier hs-var">off</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071139"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Word8]
</span><a href="#local-6989586621679071138"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-344"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-345"></span><span>    </span><span id="local-6989586621679071136"><span class="annot"><span class="annottext">loop :: Ptr b -&gt; Ptr b -&gt; [b] -&gt; IO [b]
</span><a href="#local-6989586621679071136"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071127"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071127"><span class="hs-identifier hs-var">sentinal</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071126"><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071126"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679071125"><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621679071125"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-346"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071126"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Ptr b -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071127"><span class="hs-identifier hs-var">sentinal</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[b] -&gt; IO [b]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621679071125"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-347"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679071124"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679071124"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; IO b
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071126"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-348"></span><span>                           </span><span class="annot"><span class="annottext">Ptr b -&gt; Ptr b -&gt; [b] -&gt; IO [b]
</span><a href="#local-6989586621679071136"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071127"><span class="hs-identifier hs-var">sentinal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr b
</span><a href="#local-6989586621679071126"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr b -&gt; Int -&gt; Ptr b
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621679071124"><span class="hs-identifier hs-var">x</span></a></span><span class="annot"><span class="annottext">b -&gt; [b] -&gt; [b]
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span class="annot"><span class="annottext">[b]
</span><a href="#local-6989586621679071125"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-349"></span><span>
</span><span id="line-350"></span><span class="annot"><a href="Data.ByteString.Internal.html#unpackAppendCharsStrict"><span class="hs-identifier hs-type">unpackAppendCharsStrict</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-351"></span><span id="unpackAppendCharsStrict"><span class="annot"><span class="annottext">unpackAppendCharsStrict :: ByteString -&gt; ShowS
</span><a href="Data.ByteString.Internal.html#unpackAppendCharsStrict"><span class="hs-identifier hs-var hs-var">unpackAppendCharsStrict</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071122"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071122"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679071121"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071121"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679071120"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071120"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679071119"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071119"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-352"></span><span>    </span><span class="annot"><span class="annottext">IO String -&gt; String
forall a. IO a -&gt; a
</span><a href="Data.ByteString.Internal.html#accursedUnutterablePerformIO"><span class="hs-identifier hs-var">accursedUnutterablePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO String -&gt; String) -&gt; IO String -&gt; String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO String) -&gt; IO String
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071122"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO String) -&gt; IO String)
-&gt; (Ptr Word8 -&gt; IO String) -&gt; IO String
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071118"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071118"><span class="hs-identifier hs-var">base</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-353"></span><span>      </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; String -&gt; IO String
</span><a href="#local-6989586621679071117"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071118"><span class="hs-identifier hs-var">base</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071121"><span class="hs-identifier hs-var">off</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071118"><span class="hs-identifier hs-var">base</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071121"><span class="hs-identifier hs-var">off</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071120"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071119"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-354"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-355"></span><span>    </span><span id="local-6989586621679071117"><span class="annot"><span class="annottext">loop :: Ptr Word8 -&gt; Ptr Word8 -&gt; String -&gt; IO String
</span><a href="#local-6989586621679071117"><span class="hs-identifier hs-var hs-var">loop</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071110"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071110"><span class="hs-identifier hs-var">sentinal</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679071109"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071109"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679071108"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071108"><span class="hs-identifier hs-var">acc</span></a></span></span><span>
</span><span id="line-356"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071109"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071110"><span class="hs-identifier hs-var">sentinal</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; IO String
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071108"><span class="hs-identifier hs-var">acc</span></a></span><span>
</span><span id="line-357"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679071107"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679071107"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Word8
forall a. Storable a =&gt; Ptr a -&gt; IO a
</span><a href="../../base/src/Foreign.Storable.html#peek"><span class="hs-identifier hs-var">peek</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071109"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-358"></span><span>                           </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; String -&gt; IO String
</span><a href="#local-6989586621679071117"><span class="hs-identifier hs-var">loop</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071110"><span class="hs-identifier hs-var">sentinal</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071109"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; Char
</span><a href="Data.ByteString.Internal.html#w2c"><span class="hs-identifier hs-var">w2c</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679071107"><span class="hs-identifier hs-var">x</span></a></span><span class="annot"><span class="annottext">Char -&gt; ShowS
forall a. a -&gt; [a] -&gt; [a]
</span><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-var">:</span></a></span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679071108"><span class="hs-identifier hs-var">acc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-361"></span><span>
</span><span id="line-362"></span><span class="hs-comment">-- | The 0 pointer. Used to indicate the empty Bytestring.</span><span>
</span><span id="line-363"></span><span class="annot"><a href="Data.ByteString.Internal.html#nullForeignPtr"><span class="hs-identifier hs-type">nullForeignPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-364"></span><span id="nullForeignPtr"><span class="annot"><span class="annottext">nullForeignPtr :: ForeignPtr Word8
</span><a href="Data.ByteString.Internal.html#nullForeignPtr"><span class="hs-identifier hs-var hs-var">nullForeignPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; ForeignPtrContents -&gt; ForeignPtr Word8
forall a. Addr# -&gt; ForeignPtrContents -&gt; ForeignPtr a
</span><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-var">ForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="../../ghc-prim/src/GHC.Prim.html#nullAddr%23"><span class="hs-identifier hs-var">nullAddr#</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; ForeignPtrContents
forall a. (?callStack::CallStack) =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;nullForeignPtr&quot;</span></span><span class="hs-special">)</span><span> </span><span class="hs-comment">--TODO: should ForeignPtrContents be strict?</span><span>
</span><span id="line-365"></span><span>
</span><span id="line-366"></span><span class="hs-comment">-- ---------------------------------------------------------------------</span><span>
</span><span id="line-367"></span><span class="hs-comment">-- Low level constructors</span><span>
</span><span id="line-368"></span><span>
</span><span id="line-369"></span><span class="hs-comment">-- | /O(1)/ Build a ByteString from a ForeignPtr.</span><span>
</span><span id="line-370"></span><span class="hs-comment">--</span><span>
</span><span id="line-371"></span><span class="hs-comment">-- If you do not need the offset parameter then you do should be using</span><span>
</span><span id="line-372"></span><span class="hs-comment">-- 'Data.ByteString.Unsafe.unsafePackCStringLen' or</span><span>
</span><span id="line-373"></span><span class="hs-comment">-- 'Data.ByteString.Unsafe.unsafePackCStringFinalizer' instead.</span><span>
</span><span id="line-374"></span><span class="hs-comment">--</span><span>
</span><span id="line-375"></span><span class="annot"><a href="Data.ByteString.Internal.html#fromForeignPtr"><span class="hs-identifier hs-type">fromForeignPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-376"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-comment">-- ^ Offset</span><span>
</span><span id="line-377"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-comment">-- ^ Length</span><span>
</span><span id="line-378"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-379"></span><span id="fromForeignPtr"><span class="annot"><span class="annottext">fromForeignPtr :: ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#fromForeignPtr"><span class="hs-identifier hs-var hs-var">fromForeignPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span>
</span><span id="line-380"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#fromForeignPtr"><span class="hs-pragma hs-type">fromForeignPtr</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-381"></span><span>
</span><span id="line-382"></span><span class="hs-comment">-- | /O(1)/ Deconstruct a ForeignPtr from a ByteString</span><span>
</span><span id="line-383"></span><span class="annot"><a href="Data.ByteString.Internal.html#toForeignPtr"><span class="hs-identifier hs-type">toForeignPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ^ (ptr, offset, length)</span><span>
</span><span id="line-384"></span><span id="toForeignPtr"><span class="annot"><span class="annottext">toForeignPtr :: ByteString -&gt; (ForeignPtr Word8, Int, Int)
</span><a href="Data.ByteString.Internal.html#toForeignPtr"><span class="hs-identifier hs-var hs-var">toForeignPtr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071106"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071106"><span class="hs-identifier hs-var">ps</span></a></span></span><span> </span><span id="local-6989586621679071105"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071105"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span id="local-6989586621679071104"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071104"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071106"><span class="hs-identifier hs-var">ps</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071105"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071104"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-385"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#toForeignPtr"><span class="hs-pragma hs-type">toForeignPtr</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-386"></span><span>
</span><span id="line-387"></span><span class="hs-comment">-- | A way of creating ByteStrings outside the IO monad. The @Int@</span><span>
</span><span id="line-388"></span><span class="hs-comment">-- argument gives the final size of the ByteString.</span><span>
</span><span id="line-389"></span><span class="annot"><a href="Data.ByteString.Internal.html#unsafeCreate"><span class="hs-identifier hs-type">unsafeCreate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-390"></span><span id="unsafeCreate"><span class="annot"><span class="annottext">unsafeCreate :: Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafeCreate"><span class="hs-identifier hs-var hs-var">unsafeCreate</span></a></span></span><span> </span><span id="local-6989586621679071103"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071103"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621679071102"><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO ()
</span><a href="#local-6989586621679071102"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO ByteString -&gt; ByteString
forall a. IO a -&gt; a
</span><a href="../../base/src/GHC.IO.Unsafe.html#unsafeDupablePerformIO"><span class="hs-identifier hs-var">unsafeDupablePerformIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ByteString
</span><a href="Data.ByteString.Internal.html#create"><span class="hs-identifier hs-var">create</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071103"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO ()
</span><a href="#local-6989586621679071102"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-391"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafeCreate"><span class="hs-pragma hs-type">unsafeCreate</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-392"></span><span>
</span><span id="line-393"></span><span class="hs-comment">-- | Like 'unsafeCreate' but instead of giving the final size of the</span><span>
</span><span id="line-394"></span><span class="hs-comment">-- ByteString, it is just an upper bound. The inner action returns</span><span>
</span><span id="line-395"></span><span class="hs-comment">-- the actual size. Unlike 'createAndTrim' the ByteString is not</span><span>
</span><span id="line-396"></span><span class="hs-comment">-- reallocated if the final size is less than the estimated size.</span><span>
</span><span id="line-397"></span><span class="annot"><a href="Data.ByteString.Internal.html#unsafeCreateUptoN"><span class="hs-identifier hs-type">unsafeCreateUptoN</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-398"></span><span id="unsafeCreateUptoN"><span class="annot"><span class="annottext">unsafeCreateUptoN :: Int -&gt; (Ptr Word8 -&gt; IO Int) -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafeCreateUptoN"><span class="hs-identifier hs-var hs-var">unsafeCreateUptoN</span></a></span></span><span> </span><span id="local-6989586621679071101"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071101"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621679071100"><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Int
</span><a href="#local-6989586621679071100"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO ByteString -&gt; ByteString
forall a. IO a -&gt; a
</span><a href="../../base/src/GHC.IO.Unsafe.html#unsafeDupablePerformIO"><span class="hs-identifier hs-var">unsafeDupablePerformIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO Int) -&gt; IO ByteString
</span><a href="Data.ByteString.Internal.html#createUptoN"><span class="hs-identifier hs-var">createUptoN</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071101"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Int
</span><a href="#local-6989586621679071100"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-399"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafeCreateUptoN"><span class="hs-pragma hs-type">unsafeCreateUptoN</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-400"></span><span>
</span><span id="line-401"></span><span class="hs-comment">-- | @since 0.10.12.0</span><span>
</span><span id="line-402"></span><span id="local-6989586621679071620"><span class="annot"><a href="Data.ByteString.Internal.html#unsafeCreateUptoN%27"><span class="hs-identifier hs-type">unsafeCreateUptoN'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679071620"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679071620"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-403"></span><span id="unsafeCreateUptoN%27"><span class="annot"><span class="annottext">unsafeCreateUptoN' :: forall a. Int -&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; (ByteString, a)
</span><a href="Data.ByteString.Internal.html#unsafeCreateUptoN%27"><span class="hs-identifier hs-var hs-var">unsafeCreateUptoN'</span></a></span></span><span> </span><span id="local-6989586621679071099"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071099"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621679071098"><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Int, a)
</span><a href="#local-6989586621679071098"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO (ByteString, a) -&gt; (ByteString, a)
forall a. IO a -&gt; a
</span><a href="../../base/src/GHC.IO.Unsafe.html#unsafeDupablePerformIO"><span class="hs-identifier hs-var">unsafeDupablePerformIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; IO (ByteString, a)
forall a. Int -&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; IO (ByteString, a)
</span><a href="Data.ByteString.Internal.html#createUptoN%27"><span class="hs-identifier hs-var">createUptoN'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071099"><span class="hs-identifier hs-var">l</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Int, a)
</span><a href="#local-6989586621679071098"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-404"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#unsafeCreateUptoN%27"><span class="hs-pragma hs-type">unsafeCreateUptoN'</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-405"></span><span>
</span><span id="line-406"></span><span class="hs-comment">-- | Create ByteString of size @l@ and use action @f@ to fill its contents.</span><span>
</span><span id="line-407"></span><span class="annot"><a href="Data.ByteString.Internal.html#create"><span class="hs-identifier hs-type">create</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-408"></span><span id="create"><span class="annot"><span class="annottext">create :: Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ByteString
</span><a href="Data.ByteString.Internal.html#create"><span class="hs-identifier hs-var hs-var">create</span></a></span></span><span> </span><span id="local-6989586621679071097"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071097"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621679071096"><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO ()
</span><a href="#local-6989586621679071096"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-409"></span><span>    </span><span id="local-6989586621679071095"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071095"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier hs-var">mallocByteString</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071097"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-410"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071095"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071094"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071094"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO ()
</span><a href="#local-6989586621679071096"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071094"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-411"></span><span>    </span><span class="annot"><span class="annottext">ByteString -&gt; IO ByteString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteString -&gt; IO ByteString) -&gt; ByteString -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071095"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071097"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-412"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#create"><span class="hs-pragma hs-type">create</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-413"></span><span>
</span><span id="line-414"></span><span class="hs-comment">-- | Given a maximum size @l@ and an action @f@ that fills the 'ByteString'</span><span>
</span><span id="line-415"></span><span class="hs-comment">-- starting at the given 'Ptr' and returns the actual utilized length,</span><span>
</span><span id="line-416"></span><span class="hs-comment">-- @`createUpToN'` l f@ returns the filled 'ByteString'.</span><span>
</span><span id="line-417"></span><span class="annot"><a href="Data.ByteString.Internal.html#createUptoN"><span class="hs-identifier hs-type">createUptoN</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-418"></span><span id="createUptoN"><span class="annot"><span class="annottext">createUptoN :: Int -&gt; (Ptr Word8 -&gt; IO Int) -&gt; IO ByteString
</span><a href="Data.ByteString.Internal.html#createUptoN"><span class="hs-identifier hs-var hs-var">createUptoN</span></a></span></span><span> </span><span id="local-6989586621679071092"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071092"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621679071091"><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Int
</span><a href="#local-6989586621679071091"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-419"></span><span>    </span><span id="local-6989586621679071090"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071090"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier hs-var">mallocByteString</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071092"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-420"></span><span>    </span><span id="local-6989586621679071089"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071089"><span class="hs-identifier hs-var">l'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO Int) -&gt; IO Int
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071090"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO Int) -&gt; IO Int)
-&gt; (Ptr Word8 -&gt; IO Int) -&gt; IO Int
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071088"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071088"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Int
</span><a href="#local-6989586621679071091"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071088"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-421"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO ByteString -&gt; IO ByteString
forall a. (?callStack::CallStack) =&gt; Bool -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier hs-var hs-var">assert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071089"><span class="hs-identifier hs-var">l'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071092"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO ByteString -&gt; IO ByteString) -&gt; IO ByteString -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; IO ByteString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteString -&gt; IO ByteString) -&gt; ByteString -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071090"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071089"><span class="hs-identifier hs-var">l'</span></a></span><span>
</span><span id="line-422"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#createUptoN"><span class="hs-pragma hs-type">createUptoN</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-423"></span><span>
</span><span id="line-424"></span><span class="hs-comment">-- | Like 'createUpToN', but also returns an additional value created by the</span><span>
</span><span id="line-425"></span><span class="hs-comment">-- action.</span><span>
</span><span id="line-426"></span><span class="hs-comment">--</span><span>
</span><span id="line-427"></span><span class="hs-comment">-- @since 0.10.12.0</span><span>
</span><span id="line-428"></span><span id="local-6989586621679071610"><span class="annot"><a href="Data.ByteString.Internal.html#createUptoN%27"><span class="hs-identifier hs-type">createUptoN'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679071610"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679071610"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-429"></span><span id="createUptoN%27"><span class="annot"><span class="annottext">createUptoN' :: forall a. Int -&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; IO (ByteString, a)
</span><a href="Data.ByteString.Internal.html#createUptoN%27"><span class="hs-identifier hs-var hs-var">createUptoN'</span></a></span></span><span> </span><span id="local-6989586621679071081"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071081"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621679071080"><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Int, a)
</span><a href="#local-6989586621679071080"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-430"></span><span>    </span><span id="local-6989586621679071079"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071079"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier hs-var">mallocByteString</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071081"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-431"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679071078"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071078"><span class="hs-identifier hs-var">l'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679071077"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679071077"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; IO (Int, a)
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071079"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO (Int, a)) -&gt; IO (Int, a))
-&gt; (Ptr Word8 -&gt; IO (Int, a)) -&gt; IO (Int, a)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071076"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071076"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Int, a)
</span><a href="#local-6989586621679071080"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071076"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-432"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; IO (ByteString, a) -&gt; IO (ByteString, a)
forall a. (?callStack::CallStack) =&gt; Bool -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier hs-var hs-var">assert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071078"><span class="hs-identifier hs-var">l'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071081"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(IO (ByteString, a) -&gt; IO (ByteString, a))
-&gt; IO (ByteString, a) -&gt; IO (ByteString, a)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteString, a) -&gt; IO (ByteString, a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071079"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071078"><span class="hs-identifier hs-var">l'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679071077"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-433"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#createUptoN%27"><span class="hs-pragma hs-type">createUptoN'</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-434"></span><span>
</span><span id="line-435"></span><span class="hs-comment">-- | Given the maximum size needed and a function to make the contents</span><span>
</span><span id="line-436"></span><span class="hs-comment">-- of a ByteString, createAndTrim makes the 'ByteString'. The generating</span><span>
</span><span id="line-437"></span><span class="hs-comment">-- function is required to return the actual final size (&lt;= the maximum</span><span>
</span><span id="line-438"></span><span class="hs-comment">-- size), and the resulting byte array is realloced to this size.</span><span>
</span><span id="line-439"></span><span class="hs-comment">--</span><span>
</span><span id="line-440"></span><span class="hs-comment">-- createAndTrim is the main mechanism for creating custom, efficient</span><span>
</span><span id="line-441"></span><span class="hs-comment">-- ByteString functions, using Haskell or C functions to fill the space.</span><span>
</span><span id="line-442"></span><span class="hs-comment">--</span><span>
</span><span id="line-443"></span><span class="annot"><a href="Data.ByteString.Internal.html#createAndTrim"><span class="hs-identifier hs-type">createAndTrim</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-444"></span><span id="createAndTrim"><span class="annot"><span class="annottext">createAndTrim :: Int -&gt; (Ptr Word8 -&gt; IO Int) -&gt; IO ByteString
</span><a href="Data.ByteString.Internal.html#createAndTrim"><span class="hs-identifier hs-var hs-var">createAndTrim</span></a></span></span><span> </span><span id="local-6989586621679071075"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071075"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621679071074"><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Int
</span><a href="#local-6989586621679071074"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-445"></span><span>    </span><span id="local-6989586621679071073"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071073"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier hs-var">mallocByteString</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071075"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-446"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO ByteString) -&gt; IO ByteString
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071073"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ByteString) -&gt; IO ByteString)
-&gt; (Ptr Word8 -&gt; IO ByteString) -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071072"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071072"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-447"></span><span>        </span><span id="local-6989586621679071071"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071071"><span class="hs-identifier hs-var">l'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO Int
</span><a href="#local-6989586621679071074"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071072"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-448"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
forall a. (?callStack::CallStack) =&gt; Bool -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier hs-var hs-var">assert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071071"><span class="hs-identifier hs-var">l'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071075"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071071"><span class="hs-identifier hs-var">l'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071075"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-449"></span><span>            </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; IO ByteString
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(ByteString -&gt; IO ByteString) -&gt; ByteString -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071073"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071075"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-450"></span><span>            </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ByteString
</span><a href="Data.ByteString.Internal.html#create"><span class="hs-identifier hs-var">create</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071071"><span class="hs-identifier hs-var">l'</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; IO ByteString)
-&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071070"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071070"><span class="hs-identifier hs-var">p'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
</span><a href="Data.ByteString.Internal.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071070"><span class="hs-identifier hs-var">p'</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071072"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071071"><span class="hs-identifier hs-var">l'</span></a></span><span>
</span><span id="line-451"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#createAndTrim"><span class="hs-pragma hs-type">createAndTrim</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-452"></span><span>
</span><span id="line-453"></span><span id="local-6989586621679071606"><span class="annot"><a href="Data.ByteString.Internal.html#createAndTrim%27"><span class="hs-identifier hs-type">createAndTrim'</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679071606"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621679071606"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-454"></span><span id="createAndTrim%27"><span class="annot"><span class="annottext">createAndTrim' :: forall a.
Int -&gt; (Ptr Word8 -&gt; IO (Int, Int, a)) -&gt; IO (ByteString, a)
</span><a href="Data.ByteString.Internal.html#createAndTrim%27"><span class="hs-identifier hs-var hs-var">createAndTrim'</span></a></span></span><span> </span><span id="local-6989586621679071060"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071060"><span class="hs-identifier hs-var">l</span></a></span></span><span> </span><span id="local-6989586621679071059"><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Int, Int, a)
</span><a href="#local-6989586621679071059"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-455"></span><span>    </span><span id="local-6989586621679071058"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071058"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr Word8)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier hs-var">mallocByteString</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071060"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-456"></span><span>    </span><span class="annot"><span class="annottext">ForeignPtr Word8
-&gt; (Ptr Word8 -&gt; IO (ByteString, a)) -&gt; IO (ByteString, a)
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#withForeignPtr"><span class="hs-identifier hs-var">withForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071058"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO (ByteString, a)) -&gt; IO (ByteString, a))
-&gt; (Ptr Word8 -&gt; IO (ByteString, a)) -&gt; IO (ByteString, a)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071057"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071057"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-457"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621679071056"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071056"><span class="hs-identifier hs-var">off</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679071055"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071055"><span class="hs-identifier hs-var">l'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679071054"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679071054"><span class="hs-identifier hs-var">res</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; IO (Int, Int, a)
</span><a href="#local-6989586621679071059"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071057"><span class="hs-identifier hs-var">p</span></a></span><span>
</span><span id="line-458"></span><span>        </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
forall a. (?callStack::CallStack) =&gt; Bool -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier hs-var hs-var">assert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071055"><span class="hs-identifier hs-var">l'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071060"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Bool -&gt; Bool) -&gt; Bool -&gt; Bool
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071055"><span class="hs-identifier hs-var">l'</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071060"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-459"></span><span>            </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">(ByteString, a) -&gt; IO (ByteString, a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; Int -&gt; Int -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-var">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071058"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071060"><span class="hs-identifier hs-var">l</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679071054"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-460"></span><span>            </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621679071053"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071053"><span class="hs-identifier hs-var">ps</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ByteString
</span><a href="Data.ByteString.Internal.html#create"><span class="hs-identifier hs-var">create</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071055"><span class="hs-identifier hs-var">l'</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; IO ByteString)
-&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071052"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071052"><span class="hs-identifier hs-var">p'</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-461"></span><span>                            </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
</span><a href="Data.ByteString.Internal.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071052"><span class="hs-identifier hs-var">p'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071057"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071056"><span class="hs-identifier hs-var">off</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071055"><span class="hs-identifier hs-var">l'</span></a></span><span>
</span><span id="line-462"></span><span>                    </span><span class="annot"><span class="annottext">(ByteString, a) -&gt; IO (ByteString, a)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071053"><span class="hs-identifier hs-var">ps</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679071054"><span class="hs-identifier hs-var">res</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-463"></span><span>
</span><span id="line-464"></span><span class="hs-comment">-- | Wrapper of 'Foreign.ForeignPtr.mallocForeignPtrBytes' with faster implementation for GHC</span><span>
</span><span id="line-465"></span><span class="hs-comment">--</span><span>
</span><span id="line-466"></span><span id="local-6989586621679071609"><span class="annot"><a href="Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier hs-type">mallocByteString</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.ForeignPtr.html#ForeignPtr"><span class="hs-identifier hs-type">ForeignPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679071609"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-467"></span><span id="mallocByteString"><span class="annot"><span class="annottext">mallocByteString :: forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="Data.ByteString.Internal.html#mallocByteString"><span class="hs-identifier hs-var hs-var">mallocByteString</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; IO (ForeignPtr a)
forall a. Int -&gt; IO (ForeignPtr a)
</span><a href="../../base/src/GHC.ForeignPtr.html#mallocPlainForeignPtrBytes"><span class="hs-identifier hs-var">mallocPlainForeignPtrBytes</span></a></span><span>
</span><span id="line-468"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#mallocByteString"><span class="hs-pragma hs-type">mallocByteString</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-469"></span><span>
</span><span id="line-470"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-471"></span><span class="hs-comment">-- Implementations for Eq, Ord and Monoid instances</span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span class="annot"><a href="Data.ByteString.Internal.html#eq"><span class="hs-identifier hs-type">eq</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-474"></span><span id="eq"><span class="annot"><span class="annottext">eq :: ByteString -&gt; ByteString -&gt; Bool
</span><a href="Data.ByteString.Internal.html#eq"><span class="hs-identifier hs-var hs-var">eq</span></a></span></span><span> </span><span id="local-6989586621679071051"><span class="annot"><span class="annottext">a :: ByteString
</span><a href="#local-6989586621679071051"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071050"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071050"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679071049"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071049"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679071048"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071048"><span class="hs-identifier hs-var">len</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621679071047"><span class="annot"><span class="annottext">b :: ByteString
</span><a href="#local-6989586621679071047"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071046"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071046"><span class="hs-identifier hs-var">fp'</span></a></span></span><span> </span><span id="local-6989586621679071045"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071045"><span class="hs-identifier hs-var">off'</span></a></span></span><span> </span><span id="local-6989586621679071044"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071044"><span class="hs-identifier hs-var">len'</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-475"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071048"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%2F%3D"><span class="hs-operator hs-var">/=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071044"><span class="hs-identifier hs-var">len'</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#False"><span class="hs-identifier hs-var">False</span></a></span><span>    </span><span class="hs-comment">-- short cut on length</span><span>
</span><span id="line-476"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071050"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; ForeignPtr Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071046"><span class="hs-identifier hs-var">fp'</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071049"><span class="hs-identifier hs-var">off</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071045"><span class="hs-identifier hs-var">off'</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../ghc-prim/src/GHC.Types.html#True"><span class="hs-identifier hs-var">True</span></a></span><span>     </span><span class="hs-comment">-- short cut for the same string</span><span>
</span><span id="line-477"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString -&gt; ByteString -&gt; Ordering
</span><a href="Data.ByteString.Internal.html#compareBytes"><span class="hs-identifier hs-var">compareBytes</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071051"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071047"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">Ordering -&gt; Ordering -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Ordering
</span><a href="../../ghc-prim/src/GHC.Types.html#EQ"><span class="hs-identifier hs-var">EQ</span></a></span><span>
</span><span id="line-478"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#eq"><span class="hs-pragma hs-type">eq</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-479"></span><span class="hs-comment">-- ^ still needed</span><span>
</span><span id="line-480"></span><span>
</span><span id="line-481"></span><span class="annot"><a href="Data.ByteString.Internal.html#compareBytes"><span class="hs-identifier hs-type">compareBytes</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Ordering"><span class="hs-identifier hs-type">Ordering</span></a></span><span>
</span><span id="line-482"></span><span id="compareBytes"><span class="annot"><span class="annottext">compareBytes :: ByteString -&gt; ByteString -&gt; Ordering
</span><a href="Data.ByteString.Internal.html#compareBytes"><span class="hs-identifier hs-var hs-var">compareBytes</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>    </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>    </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ordering
</span><a href="../../ghc-prim/src/GHC.Types.html#EQ"><span class="hs-identifier hs-var">EQ</span></a></span><span>  </span><span class="hs-comment">-- short cut for empty strings</span><span>
</span><span id="line-483"></span><span class="annot"><a href="Data.ByteString.Internal.html#compareBytes"><span class="hs-identifier hs-var">compareBytes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071041"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071041"><span class="hs-identifier hs-var">fp1</span></a></span></span><span> </span><span id="local-6989586621679071040"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071040"><span class="hs-identifier hs-var">off1</span></a></span></span><span> </span><span id="local-6989586621679071039"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071039"><span class="hs-identifier hs-var">len1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071038"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071038"><span class="hs-identifier hs-var">fp2</span></a></span></span><span> </span><span id="local-6989586621679071037"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071037"><span class="hs-identifier hs-var">off2</span></a></span></span><span> </span><span id="local-6989586621679071036"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071036"><span class="hs-identifier hs-var">len2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-484"></span><span>    </span><span class="annot"><span class="annottext">IO Ordering -&gt; Ordering
forall a. IO a -&gt; a
</span><a href="Data.ByteString.Internal.html#accursedUnutterablePerformIO"><span class="hs-identifier hs-var">accursedUnutterablePerformIO</span></a></span><span> </span><span class="annot"><span class="annottext">(IO Ordering -&gt; Ordering) -&gt; IO Ordering -&gt; Ordering
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-485"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO Ordering) -&gt; IO Ordering
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071041"><span class="hs-identifier hs-var">fp1</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO Ordering) -&gt; IO Ordering)
-&gt; (Ptr Word8 -&gt; IO Ordering) -&gt; IO Ordering
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071035"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071035"><span class="hs-identifier hs-var">p1</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-486"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO Ordering) -&gt; IO Ordering
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071038"><span class="hs-identifier hs-var">fp2</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO Ordering) -&gt; IO Ordering)
-&gt; (Ptr Word8 -&gt; IO Ordering) -&gt; IO Ordering
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071034"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071034"><span class="hs-identifier hs-var">p2</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-487"></span><span>        </span><span id="local-6989586621679071033"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679071033"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO CInt
</span><a href="Data.ByteString.Internal.html#memcmp"><span class="hs-identifier hs-var">memcmp</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071035"><span class="hs-identifier hs-var">p1</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071040"><span class="hs-identifier hs-var">off1</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071034"><span class="hs-identifier hs-var">p2</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071037"><span class="hs-identifier hs-var">off2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><a href="../../ghc-prim/src/GHC.Classes.html#min"><span class="hs-identifier hs-var">min</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071039"><span class="hs-identifier hs-var">len1</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071036"><span class="hs-identifier hs-var">len2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-488"></span><span>        </span><span class="annot"><span class="annottext">Ordering -&gt; IO Ordering
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(Ordering -&gt; IO Ordering) -&gt; Ordering -&gt; IO Ordering
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24%21"><span class="hs-operator hs-var">$!</span></a></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679071033"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">CInt -&gt; CInt -&gt; Ordering
forall a. Ord a =&gt; a -&gt; a -&gt; Ordering
</span><a href="../../ghc-prim/src/GHC.Classes.html#compare"><span class="hs-operator hs-var">`compare`</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><span class="hs-number">0</span></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-489"></span><span>                    </span><span class="annot"><span class="annottext">Ordering
</span><a href="../../ghc-prim/src/GHC.Types.html#EQ"><span class="hs-identifier hs-var">EQ</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071039"><span class="hs-identifier hs-var">len1</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Ordering
forall a. Ord a =&gt; a -&gt; a -&gt; Ordering
</span><a href="../../ghc-prim/src/GHC.Classes.html#compare"><span class="hs-operator hs-var">`compare`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071036"><span class="hs-identifier hs-var">len2</span></a></span><span>
</span><span id="line-490"></span><span>                    </span><span id="local-6989586621679071031"><span class="annot"><span class="annottext">Ordering
</span><a href="#local-6989586621679071031"><span class="hs-identifier hs-var">x</span></a></span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ordering
</span><a href="#local-6989586621679071031"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-491"></span><span>
</span><span id="line-492"></span><span class="annot"><a href="Data.ByteString.Internal.html#append"><span class="hs-identifier hs-type">append</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-493"></span><span id="append"><span class="annot"><span class="annottext">append :: ByteString -&gt; ByteString -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#append"><span class="hs-identifier hs-var hs-var">append</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>    </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>    </span><span id="local-6989586621679071030"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071030"><span class="hs-identifier hs-var">b</span></a></span></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071030"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-494"></span><span class="annot"><a href="Data.ByteString.Internal.html#append"><span class="hs-identifier hs-var">append</span></a></span><span> </span><span id="local-6989586621679071029"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071029"><span class="hs-identifier hs-var">a</span></a></span></span><span>                  </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>    </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071029"><span class="hs-identifier hs-var">a</span></a></span><span>
</span><span id="line-495"></span><span class="annot"><a href="Data.ByteString.Internal.html#append"><span class="hs-identifier hs-var">append</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071028"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071028"><span class="hs-identifier hs-var">fp1</span></a></span></span><span> </span><span id="local-6989586621679071027"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071027"><span class="hs-identifier hs-var">off1</span></a></span></span><span> </span><span id="local-6989586621679071026"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071026"><span class="hs-identifier hs-var">len1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679071025"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071025"><span class="hs-identifier hs-var">fp2</span></a></span></span><span> </span><span id="local-6989586621679071024"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071024"><span class="hs-identifier hs-var">off2</span></a></span></span><span> </span><span id="local-6989586621679071023"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071023"><span class="hs-identifier hs-var">len2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-496"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafeCreate"><span class="hs-identifier hs-var">unsafeCreate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071026"><span class="hs-identifier hs-var">len1</span></a></span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071023"><span class="hs-identifier hs-var">len2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; ByteString)
-&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071022"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071022"><span class="hs-identifier hs-var">destptr1</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-497"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679071021"><span class="annot"><span class="annottext">destptr2 :: Ptr Word8
</span><a href="#local-6989586621679071021"><span class="hs-identifier hs-var hs-var">destptr2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071022"><span class="hs-identifier hs-var">destptr1</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071026"><span class="hs-identifier hs-var">len1</span></a></span><span>
</span><span id="line-498"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071028"><span class="hs-identifier hs-var">fp1</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071020"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071020"><span class="hs-identifier hs-var">p1</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
</span><a href="Data.ByteString.Internal.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071022"><span class="hs-identifier hs-var">destptr1</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071020"><span class="hs-identifier hs-var">p1</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071027"><span class="hs-identifier hs-var">off1</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071026"><span class="hs-identifier hs-var">len1</span></a></span><span>
</span><span id="line-499"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679071025"><span class="hs-identifier hs-var">fp2</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071019"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071019"><span class="hs-identifier hs-var">p2</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
</span><a href="Data.ByteString.Internal.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071021"><span class="hs-identifier hs-var">destptr2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679071019"><span class="hs-identifier hs-var">p2</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071024"><span class="hs-identifier hs-var">off2</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679071023"><span class="hs-identifier hs-var">len2</span></a></span><span>
</span><span id="line-500"></span><span>
</span><span id="line-501"></span><span class="annot"><a href="Data.ByteString.Internal.html#concat"><span class="hs-identifier hs-type">concat</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#ByteString"><span class="hs-identifier hs-type">ByteString</span></a></span><span>
</span><span id="line-502"></span><span id="concat"><span class="annot"><span class="annottext">concat :: [ByteString] -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#concat"><span class="hs-identifier hs-var hs-var">concat</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679071018"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071018"><span class="hs-identifier hs-var">bss0</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; [ByteString] -&gt; ByteString
</span><a href="#local-6989586621679071017"><span class="hs-identifier hs-var">goLen0</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071018"><span class="hs-identifier hs-var">bss0</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071018"><span class="hs-identifier hs-var">bss0</span></a></span><span>
</span><span id="line-503"></span><span>    </span><span class="hs-comment">-- The idea here is we first do a pass over the input list to determine:</span><span>
</span><span id="line-504"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-505"></span><span>    </span><span class="hs-comment">--  1. is a copy necessary? e.g. @concat []@, @concat [mempty, &quot;hello&quot;]@,</span><span>
</span><span id="line-506"></span><span>    </span><span class="hs-comment">--     and @concat [&quot;hello&quot;, mempty, mempty]@ can all be handled without</span><span>
</span><span id="line-507"></span><span>    </span><span class="hs-comment">--     copying.</span><span>
</span><span id="line-508"></span><span>    </span><span class="hs-comment">--  2. if a copy is necessary, how large is the result going to be?</span><span>
</span><span id="line-509"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-510"></span><span>    </span><span class="hs-comment">-- If a copy is necessary then we create a buffer of the appropriate size</span><span>
</span><span id="line-511"></span><span>    </span><span class="hs-comment">-- and do another pass over the input list, copying the chunks into the</span><span>
</span><span id="line-512"></span><span>    </span><span class="hs-comment">-- buffer. Also, since foreign calls aren't entirely free we skip over</span><span>
</span><span id="line-513"></span><span>    </span><span class="hs-comment">-- empty chunks while copying.</span><span>
</span><span id="line-514"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-515"></span><span>    </span><span class="hs-comment">-- We pass the original [ByteString] (bss0) through as an argument through</span><span>
</span><span id="line-516"></span><span>    </span><span class="hs-comment">-- goLen0, goLen1, and goLen since we will need it again in goCopy. Passing</span><span>
</span><span id="line-517"></span><span>    </span><span class="hs-comment">-- it as an explicit argument avoids capturing it in these functions'</span><span>
</span><span id="line-518"></span><span>    </span><span class="hs-comment">-- closures which would result in unnecessary closure allocation.</span><span>
</span><span id="line-519"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-520"></span><span>    </span><span class="hs-comment">-- It's still possible that the result is empty</span><span>
</span><span id="line-521"></span><span>    </span><span id="local-6989586621679071017"><span class="annot"><span class="annottext">goLen0 :: [ByteString] -&gt; [ByteString] -&gt; ByteString
</span><a href="#local-6989586621679071017"><span class="hs-identifier hs-var hs-var">goLen0</span></a></span></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><span class="hs-identifier">_</span></span><span>    </span><span class="hs-special">[</span><span class="hs-special">]</span><span>                     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString
forall a. Monoid a =&gt; a
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var">mempty</span></a></span><span>
</span><span id="line-522"></span><span>    </span><span class="annot"><a href="#local-6989586621679071017"><span class="hs-identifier hs-var">goLen0</span></a></span><span> </span><span id="local-6989586621679071013"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071013"><span class="hs-identifier hs-var">bss0</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>     </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679071012"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071012"><span class="hs-identifier hs-var">bss</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; [ByteString] -&gt; ByteString
</span><a href="#local-6989586621679071017"><span class="hs-identifier hs-var">goLen0</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071013"><span class="hs-identifier hs-var">bss0</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071012"><span class="hs-identifier hs-var">bss</span></a></span><span>
</span><span id="line-523"></span><span>    </span><span class="annot"><a href="#local-6989586621679071017"><span class="hs-identifier hs-var">goLen0</span></a></span><span> </span><span id="local-6989586621679071011"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071011"><span class="hs-identifier hs-var">bss0</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679071010"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071010"><span class="hs-identifier hs-var">bs</span></a></span></span><span>           </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679071009"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071009"><span class="hs-identifier hs-var">bss</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; ByteString -&gt; [ByteString] -&gt; ByteString
</span><a href="#local-6989586621679071008"><span class="hs-identifier hs-var">goLen1</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071011"><span class="hs-identifier hs-var">bss0</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071010"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071009"><span class="hs-identifier hs-var">bss</span></a></span><span>
</span><span id="line-524"></span><span>
</span><span id="line-525"></span><span>    </span><span class="hs-comment">-- It's still possible that the result is a single chunk</span><span>
</span><span id="line-526"></span><span>    </span><span id="local-6989586621679071008"><span class="annot"><span class="annottext">goLen1 :: [ByteString] -&gt; ByteString -&gt; [ByteString] -&gt; ByteString
</span><a href="#local-6989586621679071008"><span class="hs-identifier hs-var hs-var">goLen1</span></a></span></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><span class="hs-identifier">_</span></span><span>    </span><span id="local-6989586621679071005"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071005"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071005"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-527"></span><span>    </span><span class="annot"><a href="#local-6989586621679071008"><span class="hs-identifier hs-var">goLen1</span></a></span><span> </span><span id="local-6989586621679071004"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071004"><span class="hs-identifier hs-var">bss0</span></a></span></span><span> </span><span id="local-6989586621679071003"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071003"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>  </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679071002"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071002"><span class="hs-identifier hs-var">bss</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; ByteString -&gt; [ByteString] -&gt; ByteString
</span><a href="#local-6989586621679071008"><span class="hs-identifier hs-var">goLen1</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071004"><span class="hs-identifier hs-var">bss0</span></a></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071003"><span class="hs-identifier hs-var">bs</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071002"><span class="hs-identifier hs-var">bss</span></a></span><span>
</span><span id="line-528"></span><span>    </span><span class="annot"><a href="#local-6989586621679071008"><span class="hs-identifier hs-var">goLen1</span></a></span><span> </span><span id="local-6989586621679071001"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071001"><span class="hs-identifier hs-var">bss0</span></a></span></span><span> </span><span id="local-6989586621679071000"><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071000"><span class="hs-identifier hs-var">bs</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679070999"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070999"><span class="hs-identifier hs-var">len</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679070998"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070998"><span class="hs-identifier hs-var">bss</span></a></span></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; Int -&gt; [ByteString] -&gt; ByteString
</span><a href="#local-6989586621679070997"><span class="hs-identifier hs-var">goLen</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679071001"><span class="hs-identifier hs-var">bss0</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; Int -&gt; Int -&gt; Int
</span><a href="Data.ByteString.Internal.html#checkedAdd"><span class="hs-identifier hs-var">checkedAdd</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;concat&quot;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070996"><span class="hs-identifier hs-var">len'</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070999"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070998"><span class="hs-identifier hs-var">bss</span></a></span><span>
</span><span id="line-529"></span><span>      </span><span class="hs-keyword">where</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679070996"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070996"><span class="hs-identifier hs-var">len'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ByteString
</span><a href="#local-6989586621679071000"><span class="hs-identifier hs-var">bs</span></a></span><span>
</span><span id="line-530"></span><span>
</span><span id="line-531"></span><span>    </span><span class="hs-comment">-- General case, just find the total length we'll need</span><span>
</span><span id="line-532"></span><span>    </span><span id="local-6989586621679070997"><span class="annot"><span class="annottext">goLen :: [ByteString] -&gt; Int -&gt; [ByteString] -&gt; ByteString
</span><a href="#local-6989586621679070997"><span class="hs-identifier hs-var hs-var">goLen</span></a></span></span><span> </span><span id="local-6989586621679070995"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070995"><span class="hs-identifier hs-var">bss0</span></a></span></span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679070994"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070994"><span class="hs-identifier hs-var">total</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679070993"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070993"><span class="hs-identifier hs-var">len</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679070992"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070992"><span class="hs-identifier hs-var">bss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; Int -&gt; [ByteString] -&gt; ByteString
</span><a href="#local-6989586621679070997"><span class="hs-identifier hs-var">goLen</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070995"><span class="hs-identifier hs-var">bss0</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070991"><span class="hs-identifier hs-var">total'</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070992"><span class="hs-identifier hs-var">bss</span></a></span><span>
</span><span id="line-533"></span><span>      </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679070991"><span class="annot"><span class="annottext">total' :: Int
</span><a href="#local-6989586621679070991"><span class="hs-identifier hs-var hs-var">total'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Int -&gt; Int -&gt; Int
</span><a href="Data.ByteString.Internal.html#checkedAdd"><span class="hs-identifier hs-var">checkedAdd</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;concat&quot;</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070994"><span class="hs-identifier hs-var">total</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070993"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-534"></span><span>    </span><span class="annot"><a href="#local-6989586621679070997"><span class="hs-identifier hs-var">goLen</span></a></span><span> </span><span id="local-6989586621679070990"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070990"><span class="hs-identifier hs-var">bss0</span></a></span></span><span> </span><span id="local-6989586621679070989"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070989"><span class="hs-identifier hs-var">total</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-535"></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString
</span><a href="Data.ByteString.Internal.html#unsafeCreate"><span class="hs-identifier hs-var">unsafeCreate</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070989"><span class="hs-identifier hs-var">total</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; ByteString)
-&gt; (Ptr Word8 -&gt; IO ()) -&gt; ByteString
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679070988"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070988"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; Ptr Word8 -&gt; IO ()
</span><a href="#local-6989586621679070987"><span class="hs-identifier hs-var">goCopy</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070990"><span class="hs-identifier hs-var">bss0</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070988"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-536"></span><span>
</span><span id="line-537"></span><span>    </span><span class="hs-comment">-- Copy the data</span><span>
</span><span id="line-538"></span><span>    </span><span id="local-6989586621679070987"><span class="annot"><span class="annottext">goCopy :: [ByteString] -&gt; Ptr Word8 -&gt; IO ()
</span><a href="#local-6989586621679070987"><span class="hs-identifier hs-var hs-var">goCopy</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>                  </span><span class="hs-glyph">!</span><span class="annot"><span class="annottext">Ptr Word8
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-539"></span><span>    </span><span class="annot"><a href="#local-6989586621679070987"><span class="hs-identifier hs-var">goCopy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><span class="hs-identifier">_</span></span><span>  </span><span class="annot"><span class="annottext">Int
</span><span class="hs-identifier">_</span></span><span>   </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>  </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679070982"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070982"><span class="hs-identifier hs-var">bss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679070981"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070981"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ByteString] -&gt; Ptr Word8 -&gt; IO ()
</span><a href="#local-6989586621679070987"><span class="hs-identifier hs-var">goCopy</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070982"><span class="hs-identifier hs-var">bss</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070981"><span class="hs-identifier hs-var">ptr</span></a></span><span>
</span><span id="line-540"></span><span>    </span><span class="annot"><a href="#local-6989586621679070987"><span class="hs-identifier hs-var">goCopy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.ByteString.Internal.html#PS"><span class="hs-identifier hs-type">PS</span></a></span><span> </span><span id="local-6989586621679070980"><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679070980"><span class="hs-identifier hs-var">fp</span></a></span></span><span> </span><span id="local-6989586621679070979"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070979"><span class="hs-identifier hs-var">off</span></a></span></span><span> </span><span id="local-6989586621679070978"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070978"><span class="hs-identifier hs-var">len</span></a></span></span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#%3A"><span class="hs-glyph hs-type">:</span></a></span><span id="local-6989586621679070977"><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070977"><span class="hs-identifier hs-var">bss</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">!</span><span id="local-6989586621679070976"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070976"><span class="hs-identifier hs-var">ptr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-541"></span><span>      </span><span class="annot"><span class="annottext">ForeignPtr Word8 -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. ForeignPtr a -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="../../base/src/GHC.ForeignPtr.html#unsafeWithForeignPtr"><span class="hs-identifier hs-var">unsafeWithForeignPtr</span></a></span><span> </span><span class="annot"><span class="annottext">ForeignPtr Word8
</span><a href="#local-6989586621679070980"><span class="hs-identifier hs-var">fp</span></a></span><span> </span><span class="annot"><span class="annottext">((Ptr Word8 -&gt; IO ()) -&gt; IO ()) -&gt; (Ptr Word8 -&gt; IO ()) -&gt; IO ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679070975"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070975"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
</span><a href="Data.ByteString.Internal.html#memcpy"><span class="hs-identifier hs-var">memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070976"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070975"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070979"><span class="hs-identifier hs-var">off</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070978"><span class="hs-identifier hs-var">len</span></a></span><span>
</span><span id="line-542"></span><span>      </span><span class="annot"><span class="annottext">[ByteString] -&gt; Ptr Word8 -&gt; IO ()
</span><a href="#local-6989586621679070987"><span class="hs-identifier hs-var">goCopy</span></a></span><span> </span><span class="annot"><span class="annottext">[ByteString]
</span><a href="#local-6989586621679070977"><span class="hs-identifier hs-var">bss</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070976"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Int -&gt; Ptr Word8
forall a b. Ptr a -&gt; Int -&gt; Ptr b
</span><a href="../../base/src/GHC.Ptr.html#plusPtr"><span class="hs-operator hs-var">`plusPtr`</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070978"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-543"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#concat"><span class="hs-pragma hs-type">concat</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-544"></span><span>
</span><span id="line-545"></span><span class="hs-pragma">{-# RULES</span><span>
</span><span id="line-546"></span><span class="annot"><span class="hs-pragma">&quot;ByteString concat [] -&gt; mempty&quot;</span></span><span>
</span><span id="line-547"></span><span>   </span><span class="annot"><a href="Data.ByteString.Internal.html#concat"><span class="hs-pragma hs-type">concat</span></a></span><span> </span><span class="hs-pragma">[</span><span class="hs-pragma">]</span><span> </span><span class="hs-pragma">=</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-pragma hs-type">mempty</span></a></span><span>
</span><span id="line-548"></span><span class="annot"><span class="hs-pragma">&quot;ByteString concat [bs] -&gt; bs&quot;</span></span><span> </span><span class="hs-pragma">forall</span><span> </span><span id="local-6989586621679070974"><span class="annot"><a href="#local-6989586621679070974"><span class="hs-pragma hs-var">x</span></a></span></span><span class="hs-pragma">.</span><span>
</span><span id="line-549"></span><span>   </span><span class="annot"><a href="Data.ByteString.Internal.html#concat"><span class="hs-pragma hs-type">concat</span></a></span><span> </span><span class="hs-pragma">[</span><span class="annot"><a href="#local-6989586621679070974"><span class="hs-pragma hs-type">x</span></a></span><span class="hs-pragma">]</span><span> </span><span class="hs-pragma">=</span><span> </span><span class="annot"><a href="#local-6989586621679070974"><span class="hs-pragma hs-type">x</span></a></span><span>
</span><span id="line-550"></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-551"></span><span>
</span><span id="line-552"></span><span class="hs-comment">-- | Add two non-negative numbers. Errors out on overflow.</span><span>
</span><span id="line-553"></span><span class="annot"><a href="Data.ByteString.Internal.html#checkedAdd"><span class="hs-identifier hs-type">checkedAdd</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-554"></span><span id="checkedAdd"><span class="annot"><span class="annottext">checkedAdd :: String -&gt; Int -&gt; Int -&gt; Int
</span><a href="Data.ByteString.Internal.html#checkedAdd"><span class="hs-identifier hs-var hs-var">checkedAdd</span></a></span></span><span> </span><span id="local-6989586621679070973"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679070973"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621679070972"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070972"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679070971"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070971"><span class="hs-identifier hs-var">y</span></a></span></span><span>
</span><span id="line-555"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070970"><span class="hs-identifier hs-var">r</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070970"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-556"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Int
forall a. String -&gt; a
</span><a href="Data.ByteString.Internal.html#overflowError"><span class="hs-identifier hs-var">overflowError</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679070973"><span class="hs-identifier hs-var">fun</span></a></span><span>
</span><span id="line-557"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679070970"><span class="annot"><span class="annottext">r :: Int
</span><a href="#local-6989586621679070970"><span class="hs-identifier hs-var hs-var">r</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070972"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070971"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-558"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#checkedAdd"><span class="hs-pragma hs-type">checkedAdd</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-559"></span><span>
</span><span id="line-560"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-561"></span><span>
</span><span id="line-562"></span><span class="hs-comment">-- | Conversion between 'Word8' and 'Char'. Should compile to a no-op.</span><span>
</span><span id="line-563"></span><span class="annot"><a href="Data.ByteString.Internal.html#w2c"><span class="hs-identifier hs-type">w2c</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span>
</span><span id="line-564"></span><span id="w2c"><span class="annot"><span class="annottext">w2c :: Word8 -&gt; Char
</span><a href="Data.ByteString.Internal.html#w2c"><span class="hs-identifier hs-var hs-var">w2c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Char
</span><a href="../../base/src/GHC.Base.html#unsafeChr"><span class="hs-identifier hs-var">unsafeChr</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Char) -&gt; (Word8 -&gt; Int) -&gt; Word8 -&gt; Char
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span>
</span><span id="line-565"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#w2c"><span class="hs-pragma hs-type">w2c</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-566"></span><span>
</span><span id="line-567"></span><span class="hs-comment">-- | Unsafe conversion between 'Char' and 'Word8'. This is a no-op and</span><span>
</span><span id="line-568"></span><span class="hs-comment">-- silently truncates to 8 bits Chars &gt; '\255'. It is provided as</span><span>
</span><span id="line-569"></span><span class="hs-comment">-- convenience for ByteString construction.</span><span>
</span><span id="line-570"></span><span class="annot"><a href="Data.ByteString.Internal.html#c2w"><span class="hs-identifier hs-type">c2w</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-571"></span><span id="c2w"><span class="annot"><span class="annottext">c2w :: Char -&gt; Word8
</span><a href="Data.ByteString.Internal.html#c2w"><span class="hs-identifier hs-var hs-var">c2w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Word8
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">(Int -&gt; Word8) -&gt; (Char -&gt; Int) -&gt; Char -&gt; Word8
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span>
</span><span id="line-572"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#c2w"><span class="hs-pragma hs-type">c2w</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-573"></span><span>
</span><span id="line-574"></span><span class="hs-comment">-- | Selects words corresponding to white-space characters in the Latin-1 range</span><span>
</span><span id="line-575"></span><span class="hs-comment">-- ordered by frequency.</span><span>
</span><span id="line-576"></span><span class="annot"><a href="Data.ByteString.Internal.html#isSpaceWord8"><span class="hs-identifier hs-type">isSpaceWord8</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-577"></span><span id="isSpaceWord8"><span class="annot"><span class="annottext">isSpaceWord8 :: Word8 -&gt; Bool
</span><a href="Data.ByteString.Internal.html#isSpaceWord8"><span class="hs-identifier hs-var hs-var">isSpaceWord8</span></a></span></span><span> </span><span id="local-6989586621679070967"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070967"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-578"></span><span>    </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070967"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x20</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span>
</span><span id="line-579"></span><span>    </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070967"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x0A</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="hs-comment">-- LF, \n</span><span>
</span><span id="line-580"></span><span>    </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070967"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x09</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="hs-comment">-- HT, \t</span><span>
</span><span id="line-581"></span><span>    </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070967"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x0C</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="hs-comment">-- FF, \f</span><span>
</span><span id="line-582"></span><span>    </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070967"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x0D</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="hs-comment">-- CR, \r</span><span>
</span><span id="line-583"></span><span>    </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070967"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0x0B</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span> </span><span class="hs-comment">-- VT, \v</span><span>
</span><span id="line-584"></span><span>    </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070967"><span class="hs-identifier hs-var">w</span></a></span><span> </span><span class="annot"><span class="annottext">Word8 -&gt; Word8 -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><span class="hs-number">0xA0</span></span><span>    </span><span class="hs-comment">-- spotted by QC..</span><span>
</span><span id="line-585"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#isSpaceWord8"><span class="hs-pragma hs-type">isSpaceWord8</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-586"></span><span>
</span><span id="line-587"></span><span class="hs-comment">-- | Selects white-space characters in the Latin-1 range</span><span>
</span><span id="line-588"></span><span class="annot"><a href="Data.ByteString.Internal.html#isSpaceChar8"><span class="hs-identifier hs-type">isSpaceChar8</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Bool"><span class="hs-identifier hs-type">Bool</span></a></span><span>
</span><span id="line-589"></span><span id="isSpaceChar8"><span class="annot"><span class="annottext">isSpaceChar8 :: Char -&gt; Bool
</span><a href="Data.ByteString.Internal.html#isSpaceChar8"><span class="hs-identifier hs-var hs-var">isSpaceChar8</span></a></span></span><span> </span><span id="local-6989586621679070965"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679070965"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-590"></span><span>    </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679070965"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">' '</span></span><span>     </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span>
</span><span id="line-591"></span><span>    </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679070965"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\t'</span></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span>
</span><span id="line-592"></span><span>    </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679070965"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\n'</span></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span>
</span><span id="line-593"></span><span>    </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679070965"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\r'</span></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span>
</span><span id="line-594"></span><span>    </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679070965"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\f'</span></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span>
</span><span id="line-595"></span><span>    </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679070965"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\v'</span></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%7C%7C"><span class="hs-operator hs-var">||</span></a></span><span>
</span><span id="line-596"></span><span>    </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679070965"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'\xa0'</span></span><span>
</span><span id="line-597"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#isSpaceChar8"><span class="hs-pragma hs-type">isSpaceChar8</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-598"></span><span>
</span><span id="line-599"></span><span id="local-6989586621679071603"><span class="annot"><a href="Data.ByteString.Internal.html#overflowError"><span class="hs-identifier hs-type">overflowError</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679071603"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-600"></span><span id="overflowError"><span class="annot"><span class="annottext">overflowError :: forall a. String -&gt; a
</span><a href="Data.ByteString.Internal.html#overflowError"><span class="hs-identifier hs-var hs-var">overflowError</span></a></span></span><span> </span><span id="local-6989586621679070962"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679070962"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; a
forall a. (?callStack::CallStack) =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">(String -&gt; a) -&gt; String -&gt; a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Data.ByteString.&quot;</span></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679070962"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; ShowS
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;: size overflow&quot;</span></span><span>
</span><span id="line-601"></span><span>
</span><span id="line-602"></span><span class="hs-comment">------------------------------------------------------------------------</span><span>
</span><span id="line-603"></span><span>
</span><span id="line-604"></span><span class="hs-comment">-- | This \&quot;function\&quot; has a superficial similarity to 'System.IO.Unsafe.unsafePerformIO' but</span><span>
</span><span id="line-605"></span><span class="hs-comment">-- it is in fact a malevolent agent of chaos. It unpicks the seams of reality</span><span>
</span><span id="line-606"></span><span class="hs-comment">-- (and the 'IO' monad) so that the normal rules no longer apply. It lulls you</span><span>
</span><span id="line-607"></span><span class="hs-comment">-- into thinking it is reasonable, but when you are not looking it stabs you</span><span>
</span><span id="line-608"></span><span class="hs-comment">-- in the back and aliases all of your mutable buffers. The carcass of many a</span><span>
</span><span id="line-609"></span><span class="hs-comment">-- seasoned Haskell programmer lie strewn at its feet.</span><span>
</span><span id="line-610"></span><span class="hs-comment">--</span><span>
</span><span id="line-611"></span><span class="hs-comment">-- Witness the trail of destruction:</span><span>
</span><span id="line-612"></span><span class="hs-comment">--</span><span>
</span><span id="line-613"></span><span class="hs-comment">-- * &lt;https://github.com/haskell/bytestring/commit/71c4b438c675aa360c79d79acc9a491e7bbc26e7&gt;</span><span>
</span><span id="line-614"></span><span class="hs-comment">--</span><span>
</span><span id="line-615"></span><span class="hs-comment">-- * &lt;https://github.com/haskell/bytestring/commit/210c656390ae617d9ee3b8bcff5c88dd17cef8da&gt;</span><span>
</span><span id="line-616"></span><span class="hs-comment">--</span><span>
</span><span id="line-617"></span><span class="hs-comment">-- * &lt;https://ghc.haskell.org/trac/ghc/ticket/3486&gt;</span><span>
</span><span id="line-618"></span><span class="hs-comment">--</span><span>
</span><span id="line-619"></span><span class="hs-comment">-- * &lt;https://ghc.haskell.org/trac/ghc/ticket/3487&gt;</span><span>
</span><span id="line-620"></span><span class="hs-comment">--</span><span>
</span><span id="line-621"></span><span class="hs-comment">-- * &lt;https://ghc.haskell.org/trac/ghc/ticket/7270&gt;</span><span>
</span><span id="line-622"></span><span class="hs-comment">--</span><span>
</span><span id="line-623"></span><span class="hs-comment">-- Do not talk about \&quot;safe\&quot;! You do not know what is safe!</span><span>
</span><span id="line-624"></span><span class="hs-comment">--</span><span>
</span><span id="line-625"></span><span class="hs-comment">-- Yield not to its blasphemous call! Flee traveller! Flee or you will be</span><span>
</span><span id="line-626"></span><span class="hs-comment">-- corrupted and devoured!</span><span>
</span><span id="line-627"></span><span class="hs-comment">--</span><span>
</span><span id="line-628"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#accursedUnutterablePerformIO"><span class="hs-pragma hs-type">accursedUnutterablePerformIO</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-629"></span><span id="local-6989586621679071618"><span class="annot"><a href="Data.ByteString.Internal.html#accursedUnutterablePerformIO"><span class="hs-identifier hs-type">accursedUnutterablePerformIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679071618"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679071618"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-630"></span><span id="accursedUnutterablePerformIO"><span class="annot"><span class="annottext">accursedUnutterablePerformIO :: forall a. IO a -&gt; a
</span><a href="Data.ByteString.Internal.html#accursedUnutterablePerformIO"><span class="hs-identifier hs-var hs-var">accursedUnutterablePerformIO</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span id="local-6989586621679070961"><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, a #)
</span><a href="#local-6989586621679070961"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">State# RealWorld -&gt; (# State# RealWorld, a #)
</span><a href="#local-6989586621679070961"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><a href="../../ghc-prim/src/GHC.Prim.html#realWorld%23"><span class="hs-identifier hs-var">realWorld#</span></a></span><span> </span><span class="hs-keyword">of</span><span> </span><span class="hs-special">(#</span><span> </span><span class="annot"><span class="annottext">State# RealWorld
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679070960"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679070960"><span class="hs-identifier hs-var">r</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679070960"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-631"></span><span>
</span><span id="line-632"></span><span id="local-6989586621679070959"><span class="annot"><a href="Data.ByteString.Internal.html#inlinePerformIO"><span class="hs-identifier hs-type">inlinePerformIO</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679070959"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679070959"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-633"></span><span id="inlinePerformIO"><span class="annot"><span class="annottext">inlinePerformIO :: forall a. IO a -&gt; a
</span><a href="Data.ByteString.Internal.html#inlinePerformIO"><span class="hs-identifier hs-var hs-var">inlinePerformIO</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IO a -&gt; a
forall a. IO a -&gt; a
</span><a href="Data.ByteString.Internal.html#accursedUnutterablePerformIO"><span class="hs-identifier hs-var">accursedUnutterablePerformIO</span></a></span><span>
</span><span id="line-634"></span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="Data.ByteString.Internal.html#inlinePerformIO"><span class="hs-pragma hs-type">inlinePerformIO</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-635"></span><span class="hs-pragma">{-# DEPRECATED</span><span> </span><span class="hs-pragma">inlinePerformIO</span><span> </span><span class="hs-pragma">&quot;If you think you know what you are doing, use 'System.IO.Unsafe.unsafePerformIO'. If you are sure you know what you are doing, use 'unsafeDupablePerformIO'. If you enjoy sharing an address space with a malevolent agent of chaos, try 'accursedUnutterablePerformIO'.&quot;</span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-636"></span><span>
</span><span id="line-637"></span><span class="hs-comment">-- ---------------------------------------------------------------------</span><span>
</span><span id="line-638"></span><span class="hs-comment">--</span><span>
</span><span id="line-639"></span><span class="hs-comment">-- Standard C functions</span><span>
</span><span id="line-640"></span><span class="hs-comment">--</span><span>
</span><span id="line-641"></span><span>
</span><span id="line-642"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;string.h strlen&quot;</span></span><span> </span><span id="c_strlen"><span class="annot"><a href="Data.ByteString.Internal.html#c_strlen"><span class="hs-identifier hs-var">c_strlen</span></a></span></span><span>
</span><span id="line-643"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.String.html#CString"><span class="hs-identifier hs-type">CString</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span>
</span><span id="line-644"></span><span>
</span><span id="line-645"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;static stdlib.h &amp;free&quot;</span></span><span> </span><span id="c_free_finalizer"><span class="annot"><a href="Data.ByteString.Internal.html#c_free_finalizer"><span class="hs-identifier hs-var">c_free_finalizer</span></a></span></span><span>
</span><span id="line-646"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#FunPtr"><span class="hs-identifier hs-type">FunPtr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-647"></span><span>
</span><span id="line-648"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;string.h memchr&quot;</span></span><span> </span><span id="c_memchr"><span class="annot"><a href="Data.ByteString.Internal.html#c_memchr"><span class="hs-identifier hs-var">c_memchr</span></a></span></span><span>
</span><span id="line-649"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-650"></span><span>
</span><span id="line-651"></span><span class="annot"><a href="Data.ByteString.Internal.html#memchr"><span class="hs-identifier hs-type">memchr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-652"></span><span id="memchr"><span class="annot"><span class="annottext">memchr :: Ptr Word8 -&gt; Word8 -&gt; CSize -&gt; IO (Ptr Word8)
</span><a href="Data.ByteString.Internal.html#memchr"><span class="hs-identifier hs-var hs-var">memchr</span></a></span></span><span> </span><span id="local-6989586621679070957"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070957"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679070956"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070956"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621679070955"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679070955"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; CInt -&gt; CSize -&gt; IO (Ptr Word8)
</span><a href="Data.ByteString.Internal.html#c_memchr"><span class="hs-identifier hs-var">c_memchr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070957"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070956"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679070955"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-653"></span><span>
</span><span id="line-654"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;string.h memcmp&quot;</span></span><span> </span><span id="c_memcmp"><span class="annot"><a href="Data.ByteString.Internal.html#c_memcmp"><span class="hs-identifier hs-var">c_memcmp</span></a></span></span><span>
</span><span id="line-655"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-656"></span><span>
</span><span id="line-657"></span><span class="annot"><a href="Data.ByteString.Internal.html#memcmp"><span class="hs-identifier hs-type">memcmp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-658"></span><span id="memcmp"><span class="annot"><span class="annottext">memcmp :: Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO CInt
</span><a href="Data.ByteString.Internal.html#memcmp"><span class="hs-identifier hs-var hs-var">memcmp</span></a></span></span><span> </span><span id="local-6989586621679070953"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070953"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679070952"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070952"><span class="hs-identifier hs-var">q</span></a></span></span><span> </span><span id="local-6989586621679070951"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070951"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; CSize -&gt; IO CInt
</span><a href="Data.ByteString.Internal.html#c_memcmp"><span class="hs-identifier hs-var">c_memcmp</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070953"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070952"><span class="hs-identifier hs-var">q</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070951"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-659"></span><span>
</span><span id="line-660"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;string.h memcpy&quot;</span></span><span> </span><span id="c_memcpy"><span class="annot"><a href="Data.ByteString.Internal.html#c_memcpy"><span class="hs-identifier hs-var">c_memcpy</span></a></span></span><span>
</span><span id="line-661"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-662"></span><span>
</span><span id="line-663"></span><span class="annot"><a href="Data.ByteString.Internal.html#memcpy"><span class="hs-identifier hs-type">memcpy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-664"></span><span id="memcpy"><span class="annot"><span class="annottext">memcpy :: Ptr Word8 -&gt; Ptr Word8 -&gt; Int -&gt; IO ()
</span><a href="Data.ByteString.Internal.html#memcpy"><span class="hs-identifier hs-var hs-var">memcpy</span></a></span></span><span> </span><span id="local-6989586621679070949"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070949"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679070948"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070948"><span class="hs-identifier hs-var">q</span></a></span></span><span> </span><span id="local-6989586621679070947"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070947"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; Ptr Word8 -&gt; CSize -&gt; IO (Ptr Word8)
</span><a href="Data.ByteString.Internal.html#c_memcpy"><span class="hs-identifier hs-var">c_memcpy</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070949"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070948"><span class="hs-identifier hs-var">q</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; CSize
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679070947"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IO (Ptr Word8) -&gt; IO () -&gt; IO ()
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; m b -&gt; m b
</span><a href="../../base/src/GHC.Base.html#%3E%3E"><span class="hs-operator hs-var">&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">() -&gt; IO ()
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-665"></span><span>
</span><span id="line-666"></span><span class="hs-comment">{-
foreign import ccall unsafe &quot;string.h memmove&quot; c_memmove
    :: Ptr Word8 -&gt; Ptr Word8 -&gt; CSize -&gt; IO (Ptr Word8)

memmove :: Ptr Word8 -&gt; Ptr Word8 -&gt; CSize -&gt; IO ()
memmove p q s = do c_memmove p q s
                   return ()
-}</span><span>
</span><span id="line-674"></span><span>
</span><span id="line-675"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;string.h memset&quot;</span></span><span> </span><span id="c_memset"><span class="annot"><a href="Data.ByteString.Internal.html#c_memset"><span class="hs-identifier hs-var">c_memset</span></a></span></span><span>
</span><span id="line-676"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-677"></span><span>
</span><span id="line-678"></span><span class="annot"><a href="Data.ByteString.Internal.html#memset"><span class="hs-identifier hs-type">memset</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CSize"><span class="hs-identifier hs-type">CSize</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-679"></span><span id="memset"><span class="annot"><span class="annottext">memset :: Ptr Word8 -&gt; Word8 -&gt; CSize -&gt; IO (Ptr Word8)
</span><a href="Data.ByteString.Internal.html#memset"><span class="hs-identifier hs-var hs-var">memset</span></a></span></span><span> </span><span id="local-6989586621679070945"><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070945"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span id="local-6989586621679070944"><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070944"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span id="local-6989586621679070943"><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679070943"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Ptr Word8 -&gt; CInt -&gt; CSize -&gt; IO (Ptr Word8)
</span><a href="Data.ByteString.Internal.html#c_memset"><span class="hs-identifier hs-var">c_memset</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Word8
</span><a href="#local-6989586621679070945"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word8 -&gt; CInt
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word8
</span><a href="#local-6989586621679070944"><span class="hs-identifier hs-var">w</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CSize
</span><a href="#local-6989586621679070943"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-680"></span><span>
</span><span id="line-681"></span><span class="hs-comment">-- ---------------------------------------------------------------------</span><span>
</span><span id="line-682"></span><span class="hs-comment">--</span><span>
</span><span id="line-683"></span><span class="hs-comment">-- Uses our C code</span><span>
</span><span id="line-684"></span><span class="hs-comment">--</span><span>
</span><span id="line-685"></span><span>
</span><span id="line-686"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;static fpstring.h fps_reverse&quot;</span></span><span> </span><span id="c_reverse"><span class="annot"><a href="Data.ByteString.Internal.html#c_reverse"><span class="hs-identifier hs-var">c_reverse</span></a></span></span><span>
</span><span id="line-687"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CULong"><span class="hs-identifier hs-type">CULong</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-688"></span><span>
</span><span id="line-689"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;static fpstring.h fps_intersperse&quot;</span></span><span> </span><span id="c_intersperse"><span class="annot"><a href="Data.ByteString.Internal.html#c_intersperse"><span class="hs-identifier hs-var">c_intersperse</span></a></span></span><span>
</span><span id="line-690"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CULong"><span class="hs-identifier hs-type">CULong</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-691"></span><span>
</span><span id="line-692"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;static fpstring.h fps_maximum&quot;</span></span><span> </span><span id="c_maximum"><span class="annot"><a href="Data.ByteString.Internal.html#c_maximum"><span class="hs-identifier hs-var">c_maximum</span></a></span></span><span>
</span><span id="line-693"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CULong"><span class="hs-identifier hs-type">CULong</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-694"></span><span>
</span><span id="line-695"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;static fpstring.h fps_minimum&quot;</span></span><span> </span><span id="c_minimum"><span class="annot"><a href="Data.ByteString.Internal.html#c_minimum"><span class="hs-identifier hs-var">c_minimum</span></a></span></span><span>
</span><span id="line-696"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CULong"><span class="hs-identifier hs-type">CULong</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span>
</span><span id="line-697"></span><span>
</span><span id="line-698"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span class="annot"><span class="hs-string">&quot;static fpstring.h fps_count&quot;</span></span><span> </span><span id="c_count"><span class="annot"><a href="Data.ByteString.Internal.html#c_count"><span class="hs-identifier hs-var">c_count</span></a></span></span><span>
</span><span id="line-699"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CULong"><span class="hs-identifier hs-type">CULong</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Word.html#Word8"><span class="hs-identifier hs-type">Word8</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="../../base/src/Foreign.C.Types.html#CULong"><span class="hs-identifier hs-type">CULong</span></a></span><span>
</span><span id="line-700"></span></pre></body></html>